// Path: kite-core/src/main/java/edu/umn/cs/kite/util/ConstantsAndDefaults.java
// public class ConstantsAndDefaults {
//     public static long GC_PERIOD_MILLISECONDS = 15*60*1000;
//     public static long LOG_PERIOD_MILLISECONDS = 2*60*1000;
//     public static int FILE_BLK_SIZE_BYTES = 128*1024*1024*1;
//     public static int BUFFER_SIZE_BYTES = 4096 * 1024;
//     public static int RECOVERY_BLK_SIZE_BYTES = 64*1024*1024*1;
// 
//     //Memory data constants
//     public final static int MAX_MEMORY_CHUNK_CAPACITY = 3000000;
//     public final static double MEMORY_DATA_FLUSH_THRESHOLD = 0.2;
// 
//     //Memory indexes
//     public static int MEMORY_INDEX_DEFAULT_SEGMENTS = 5;
//     public static final long BATCH_UPDATE_TIME_MILLISECONDS = 3000;
//     public static final int TEMPORAL_FLUSHING_PERIODIC_TIME_MINUTES = 360;
//     public static final int TEMPORAL_FLUSHING_PERIODIC_DATA_SIZE = 1000000;
// 
//     public static int MEMORY_INDEX_CAPACITY =
//             TEMPORAL_FLUSHING_PERIODIC_DATA_SIZE;
// 
//     //Disk indexes
//     public static String DISK_INDEXES_ROOT_DIRECTORY;
//     public static final int NUM_DISK_SEGMENTS_IN_MEMORY_DIRECTORY = 10;
// 
//     //Query default values
//     public static int QUERY_ANSWER_SIZE = 20;
//     public static long QUERY_TIME = 3*60*60*1000;//3 hours
//     public static TemporalPeriod QUERY_TIME() {
//         long to = new Date().getTime();
//         long from = to - QUERY_TIME;
//         return new TemporalPeriod(from, to);
//     }
// }
// 
// Path: kite-core/src/main/java/edu/umn/cs/kite/util/GC.java
// public class GC implements Runnable {
//     public static void invoke() {
//         Thread gcThread = new Thread(new GC());
//         gcThread.start();
//     }
// 
//     @Override
//     public void run() {
//         System.gc();
//     }
// }


import edu.umn.cs.kite.util.ConstantsAndDefaults;
import edu.umn.cs.kite.util.GC;
import org.apache.ignite.Ignite;
import org.apache.ignite.Ignition;
import org.apache.ignite.configuration.IgniteConfiguration;
import java.util.Timer;
import java.util.TimerTask;
package edu.umn.cs.kite.common;

/**
 * Created by amr_000 on 8/1/2016.
 */


public class KiteLaunchTool {
    private Ignite cluster = null;
    private String configurationXMLFile = null;
    private Timer gcTimer;

    public Ignite getCluster() { return cluster; }

    public KiteLaunchTool(String configurationXML) {
        cluster = Ignition.start(configurationXML);
        init();
    }
    public KiteLaunchTool() {
        boolean peerClassLoading = true;
        IgniteConfiguration config = new IgniteConfiguration();
        config.setPeerClassLoadingEnabled(peerClassLoading);
        cluster = Ignition.start(config);
        init();
    }

    private void init(){
        printKiteName();
        startGCTimer();
    }

    private void startGCTimer() {
        gcTimer = new Timer(true);
// Path: kite-core/src/main/java/edu/umn/cs/kite/util/ConstantsAndDefaults.java
// public class ConstantsAndDefaults {
//     public static long GC_PERIOD_MILLISECONDS = 15*60*1000;
//     public static long LOG_PERIOD_MILLISECONDS = 2*60*1000;
//     public static int FILE_BLK_SIZE_BYTES = 128*1024*1024*1;
//     public static int BUFFER_SIZE_BYTES = 4096 * 1024;
//     public static int RECOVERY_BLK_SIZE_BYTES = 64*1024*1024*1;
// 
//     //Memory data constants
//     public final static int MAX_MEMORY_CHUNK_CAPACITY = 3000000;
//     public final static double MEMORY_DATA_FLUSH_THRESHOLD = 0.2;
// 
//     //Memory indexes
//     public static int MEMORY_INDEX_DEFAULT_SEGMENTS = 5;
//     public static final long BATCH_UPDATE_TIME_MILLISECONDS = 3000;
//     public static final int TEMPORAL_FLUSHING_PERIODIC_TIME_MINUTES = 360;
//     public static final int TEMPORAL_FLUSHING_PERIODIC_DATA_SIZE = 1000000;
// 
//     public static int MEMORY_INDEX_CAPACITY =
//             TEMPORAL_FLUSHING_PERIODIC_DATA_SIZE;
// 
//     //Disk indexes
//     public static String DISK_INDEXES_ROOT_DIRECTORY;
//     public static final int NUM_DISK_SEGMENTS_IN_MEMORY_DIRECTORY = 10;
// 
//     //Query default values
//     public static int QUERY_ANSWER_SIZE = 20;
//     public static long QUERY_TIME = 3*60*60*1000;//3 hours
//     public static TemporalPeriod QUERY_TIME() {
//         long to = new Date().getTime();
//         long from = to - QUERY_TIME;
//         return new TemporalPeriod(from, to);
//     }
// }
// 
// Path: kite-core/src/main/java/edu/umn/cs/kite/util/GC.java
// public class GC implements Runnable {
//     public static void invoke() {
//         Thread gcThread = new Thread(new GC());
//         gcThread.start();
//     }
// 
//     @Override
//     public void run() {
//         System.gc();
//     }
// }


// Path: kite-core/src/main/java/edu/umn/cs/kite/common/KiteLaunchTool.java
import edu.umn.cs.kite.util.ConstantsAndDefaults;
import edu.umn.cs.kite.util.GC;
import org.apache.ignite.Ignite;
import org.apache.ignite.Ignition;
import org.apache.ignite.configuration.IgniteConfiguration;
import java.util.Timer;
import java.util.TimerTask;

package edu.umn.cs.kite.common;

/**
 * Created by amr_000 on 8/1/2016.
 */


public class KiteLaunchTool {
    private Ignite cluster = null;
    private String configurationXMLFile = null;
    private Timer gcTimer;

    public Ignite getCluster() { return cluster; }

    public KiteLaunchTool(String configurationXML) {
        cluster = Ignition.start(configurationXML);
        init();
    }
    public KiteLaunchTool() {
        boolean peerClassLoading = true;
        IgniteConfiguration config = new IgniteConfiguration();
        config.setPeerClassLoadingEnabled(peerClassLoading);
        cluster = Ignition.start(config);
        init();
    }

    private void init(){
        printKiteName();
        startGCTimer();
    }

    private void startGCTimer() {
        gcTimer = new Timer(true);
        long timerPeriod = ConstantsAndDefaults.GC_PERIOD_MILLISECONDS;