Example usage for java.io File getAbsoluteFile

List of usage examples for java.io File getAbsoluteFile

Introduction

In this page you can find the example usage for java.io File getAbsoluteFile.

Prototype

public File getAbsoluteFile() 

Source Link

Document

Returns the absolute form of this abstract pathname.

Usage

From source file:com.newproject.ApacheHttp.java

public static void main(String[] args) throws Exception {
    CloseableHttpClient httpclient = HttpClients.createDefault();
    String jsonFilePath = "/Users/vikasmohandoss/Documents/Cloud/test.txt";
    String url = "http://www.sentiment140.com/api/bulkClassifyJson&appid=vm2446@columbia.edu";
    JSONParser jsonParser = new JSONParser();
    JSONObject jsonObject = new JSONObject();
    URL obj = new URL(url);
    HttpURLConnection con = (HttpURLConnection) obj.openConnection();
    try {//from  ww  w  .  j  ava  2  s  .  c om
        FileReader fileReader = new FileReader(jsonFilePath);
        jsonObject = (JSONObject) jsonParser.parse(fileReader);
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } catch (ParseException e) {
        e.printStackTrace();
    }
    System.out.println(jsonObject.toString());
    /*try {
    /*HttpGet httpGet = new HttpGet("http://httpbin.org/get");
    CloseableHttpResponse response1 = httpclient.execute(httpGet);
    // The underlying HTTP connection is still held by the response object
    // to allow the response content to be streamed directly from the network socket.
    // In order to ensure correct deallocation of system resources
    // the user MUST call CloseableHttpResponse#close() from a finally clause.
    // Please note that if response content is not fully consumed the underlying
    // connection cannot be safely re-used and will be shut down and discarded
    // by the connection manager.
    try {
        System.out.println(response1.getStatusLine());
        HttpEntity entity1 = response1.getEntity();
        // do something useful with the response body
        // and ensure it is fully consumed
        EntityUtils.consume(entity1);
    } finally {
        response1.close();
    }
    HttpPost httpPost = new HttpPost("http://httpbin.org/post");
    List <NameValuePair> nvps = new ArrayList <NameValuePair>();
    nvps.add(new BasicNameValuePair("username", "vip"));
    nvps.add(new BasicNameValuePair("password", "secret"));
    httpPost.setEntity(new UrlEncodedFormEntity(nvps));
    CloseableHttpResponse response2 = httpclient.execute(httpPost);
            
    try {
        System.out.println(response2.getStatusLine());
        HttpEntity entity2 = response2.getEntity();
        // do something useful with the response body
        // and ensure it is fully consumed
        EntityUtils.consume(entity2);
    } finally {
        response2.close();
    }
    } finally {
    httpclient.close();
    }*/
    try {
        HttpPost request = new HttpPost("http://www.sentiment140.com/api/bulkClassifyJson");
        StringEntity params = new StringEntity(jsonObject.toString());
        request.addHeader("content-type", "application/json");
        request.setEntity(params);
        HttpResponse response = httpclient.execute(request);
        System.out.println(response.toString());
        String result = EntityUtils.toString(response.getEntity());
        System.out.println(result);
        try {
            File file = new File("/Users/vikasmohandoss/Documents/Cloud/sentiment.txt");
            // if file doesnt exists, then create it
            if (!file.exists()) {
                file.createNewFile();
            }
            FileWriter fw = new FileWriter(file.getAbsoluteFile());
            BufferedWriter bw = new BufferedWriter(fw);
            bw.write(result);
            bw.close();
            System.out.println("Done");
        } catch (IOException e) {
            e.printStackTrace();
        }
        // handle response here...
    } catch (Exception ex) {
        // handle exception here
    } finally {
        httpclient.close();
    }
}

From source file:de.cwclan.cwsa.serverendpoint.main.ServerEndpoint.java

/**
 * @param args the command line arguments
 *//*from  ww  w . j a  v a  2  s. c  o m*/
public static void main(String[] args) {
    Options options = new Options();
    options.addOption(OptionBuilder.withArgName("file").hasArg().withDescription(
            "Used to enter path of configfile. Default file is endpoint.properties. NOTE: If the file is empty or does not exsist, a default config is created.")
            .create("config"));
    options.addOption("h", "help", false, "displays this page");
    CommandLineParser parser = new PosixParser();
    Properties properties = new Properties();
    try {
        /*
         * parse default config shipped with jar
         */
        CommandLine cmd = parser.parse(options, args);

        /*
         * load default configuration
         */
        InputStream in = ServerEndpoint.class.getResourceAsStream("/endpoint.properties");
        if (in == null) {
            throw new IOException("Unable to load default config from JAR. This should not happen.");
        }
        properties.load(in);
        in.close();
        log.debug("Loaded default config base: {}", properties.toString());
        if (cmd.hasOption("help")) {
            printHelp(options);
            System.exit(0);
        }

        /*
         * parse cutom config if exists, otherwise create default cfg
         */
        if (cmd.hasOption("config")) {
            File file = new File(cmd.getOptionValue("config", "endpoint.properties"));
            if (file.exists() && file.canRead() && file.isFile()) {
                in = new FileInputStream(file);
                properties.load(in);
                log.debug("Loaded custom config from {}: {}", file.getAbsoluteFile(), properties);
            } else {
                log.warn("Config file does not exsist. A default file will be created.");
            }
            FileWriter out = new FileWriter(file);
            properties.store(out,
                    "Warning, this file is recreated on every startup to merge missing parameters.");
        }

        /*
         * create and start endpoint
         */
        log.info("Config read successfull. Values are: {}", properties);
        ServerEndpoint endpoint = new ServerEndpoint(properties);
        Runtime.getRuntime().addShutdownHook(endpoint.getShutdownHook());
        endpoint.start();
    } catch (IOException ex) {
        log.error("Error while reading config.", ex);
    } catch (ParseException ex) {
        log.error("Error while parsing commandline options: {}", ex.getMessage());
        printHelp(options);
        System.exit(1);
    }
}

From source file:it.sayservice.platform.smartplanner.utils.LegGenerator.java

public static void main(String[] args) throws IOException {

    Mongo m = new Mongo("localhost"); // default port 27017
    DB db = m.getDB("smart-planner-15x");
    DBCollection coll = db.getCollection("stops");

    // read trips.txt(trips,serviceId).
    List<String[]> trips = readFileGetLines("src/main/resources/schedules/17/trips.txt");
    List<String[]> stopTimes = readFileGetLines("src/main/resources/schedules/17/stop_times.txt");
    for (String[] words : trips) {
        try {//  ww  w  .ja  va2  s  . c om
            String routeId = words[0].trim();
            String serviceId = words[1].trim();
            String tripId = words[2].trim();
            // fetch schedule for trips.
            for (int i = 0; i < stopTimes.size(); i++) {
                // already ordered by occurence.
                String[] scheduleLeg = stopTimes.get(i);
                if (scheduleLeg[0].equalsIgnoreCase(tripId)) {
                    // check if next leg belongs to same trip
                    if (stopTimes.get(i + 1)[0].equalsIgnoreCase(tripId)) {

                        String arrivalT = scheduleLeg[1];
                        String departT = scheduleLeg[2];
                        String sourceId = scheduleLeg[3];
                        String destId = stopTimes.get(i + 1)[3];
                        // get coordinates of stops.
                        /**
                         * make sure that mongo stop collection is
                         * populated. if, not, invoke
                         * http://localhost:7070/smart
                         * -planner/rest/getTransitTimes
                         * /TB_R2_R/1366776000000/1366819200000
                         */
                        Stop source = (Stop) getObjectByField(db, "id", sourceId, coll, Stop.class);
                        Stop destination = (Stop) getObjectByField(db, "id", destId, coll, Stop.class);
                        // System.out.println(tripId + ","
                        // + routeId + ","
                        // + source.getId() + ","
                        // + source.getLatitude() + ","
                        // + source.getLongitude() + ","
                        // + arrivalT + ","
                        // + destination.getId() + ","
                        // + destination.getLatitude() + ","
                        // + destination.getLongitude() + ","
                        // + departT + ","
                        // + serviceId
                        // );
                        String content = tripId + "," + routeId + "," + source.getStopId() + ","
                                + source.getLatitude() + "," + source.getLongitude() + "," + arrivalT + ","
                                + destination.getStopId() + "," + destination.getLatitude() + ","
                                + destination.getLongitude() + "," + departT + "," + "Giornaliero" + "\n";

                        File file = new File("src/main/resources/legs/legs.txt");
                        // single leg file
                        if (!file.exists()) {
                            file.createNewFile();
                        }

                        FileWriter fw = new FileWriter(file.getAbsoluteFile(), true);
                        BufferedWriter bw = new BufferedWriter(fw);
                        bw.write(content);
                        bw.close();
                        // individual trip leg file.
                        File fileT = new File("src/main/resources/legs/legs_" + routeId + ".txt");
                        FileWriter fwT = new FileWriter(fileT.getAbsoluteFile(), true);
                        BufferedWriter bwT = new BufferedWriter(fwT);
                        bwT.write(content);
                        bwT.close();

                    }
                }
            }

        } catch (Exception e) {
            System.out.println("Error parsing trip: " + words[0] + "," + words[1] + "," + words[2]);
        }
    }
    System.out.println("Done");
}

From source file:eu.cognitum.readandwrite.App.java

public static void main(String[] args) {
    try {//  w  w  w . jav  a 2  s  .  c om
        String configFile = 0 == args.length ? "example.properties" : args[0];

        CONFIGURATION = new Properties();
        File f = new File(configFile);
        if (!f.exists()) {
            LOGGER.warning("configuration not found at " + configFile);
            return;
        }
        LOGGER.info("loading configuration file " + f.getAbsoluteFile());
        CONFIGURATION.load(new FileInputStream(f));

        String ip = CONFIGURATION.getProperty(PROP_STORAGE_HOSTNAME);
        String keyspace = CONFIGURATION.getProperty(PROP_STORAGE_KEYSPACE);
        String directory = CONFIGURATION.getProperty(PROP_STORAGE_DIRECTORY);

        // N of articles to be generated.
        int Narticles = 100000;
        // size of the buffer to commit each time
        int commitBufferSize = 100;
        // N of articles to commit before trying reads
        int readStep = 100;

        String currentNamespace = "http://mynamespace#";
        LOGGER.log(Level.INFO, "Generating the rdf...");
        GenerateRdf rdfGenerator = new GenerateRdf(currentNamespace, "tmp.rdf");
        rdfGenerator.generateAndSaveRdf(Narticles);
        LOGGER.log(Level.INFO, "Generated the rdf!");
        ArrayList<SimulateReadAndWrite> simulateAll = new ArrayList<SimulateReadAndWrite>();

        int Ndbs = 0;

        DBS[] chosenDbs = { DBS.NATIVE };
        //DBS[] chosenDbs = DBS.values();

        for (DBS dbs : chosenDbs) {
            SailRepository sr;

            switch (dbs) {
            case NATIVE:
                sr = createNativeStoreConnection(directory);
                break;
            case TITAN:
                sr = createTitanConnection(ip, keyspace);
                break;
            case NEO4J:
                sr = createNeo4jConnection(keyspace);
                break;
            case ORIENT:
                sr = createOrientConnection(keyspace);
                break;
            default:
                sr = null;
                break;
            }

            if (sr == null) {
                throw new Exception("Something wrong while connecting to " + dbs.toString());
            }

            simulateAll.add(new SimulateReadAndWrite(sr, "test" + dbs.toString(), Narticles, readStep,
                    commitBufferSize, dbs.toString(), keyspace, currentNamespace, rdfGenerator));

            simulateAll.get(Ndbs).start();
            Ndbs++;
        }

        int Nfinished = 0;
        int k;
        while (Nfinished != Ndbs) {
            Nfinished = 0;
            k = 0;
            for (DBS dbs : chosenDbs) {
                if (simulateAll.get(k).IsProcessCompleted()) {
                    Nfinished++;
                } else {
                    System.out.println(String.format("Process for db %s is at %.2f", dbs.toString(),
                            simulateAll.get(k).GetProgress()));
                }
                k++;
            }
            Thread.sleep(10000);
        }

    } catch (Exception ex) {
        LOGGER.log(Level.SEVERE, null, ex);
    }
}

From source file:net.sf.mcf2pdf.Main.java

@SuppressWarnings("static-access")
public static void main(String[] args) {
    Options options = new Options();

    Option o = OptionBuilder.hasArg().isRequired()
            .withDescription("Installation location of My CEWE Photobook. REQUIRED.").create('i');
    options.addOption(o);//from w ww  . j  av  a  2 s  . co m
    options.addOption("h", false, "Prints this help and exits.");
    options.addOption("t", true, "Location of MCF temporary files.");
    options.addOption("w", true, "Location for temporary images generated during conversion.");
    options.addOption("r", true, "Sets the resolution to use for page rendering, in DPI. Default is 150.");
    options.addOption("n", true, "Sets the page number to render up to. Default renders all pages.");
    options.addOption("b", false, "Prevents rendering of binding between double pages.");
    options.addOption("x", false, "Generates only XSL-FO content instead of PDF content.");
    options.addOption("q", false, "Quiet mode - only errors are logged.");
    options.addOption("d", false, "Enables debugging logging output.");

    CommandLine cl;
    try {
        CommandLineParser parser = new PosixParser();
        cl = parser.parse(options, args);
    } catch (ParseException pe) {
        printUsage(options, pe);
        System.exit(3);
        return;
    }

    if (cl.hasOption("h")) {
        printUsage(options, null);
        return;
    }

    if (cl.getArgs().length != 2) {
        printUsage(options,
                new ParseException("INFILE and OUTFILE must be specified. Arguments were: " + cl.getArgList()));
        System.exit(3);
        return;
    }

    File installDir = new File(cl.getOptionValue("i"));
    if (!installDir.isDirectory()) {
        printUsage(options, new ParseException("Specified installation directory does not exist."));
        System.exit(3);
        return;
    }

    File tempDir = null;
    String sTempDir = cl.getOptionValue("t");
    if (sTempDir == null) {
        tempDir = new File(new File(System.getProperty("user.home")), ".mcf");
        if (!tempDir.isDirectory()) {
            printUsage(options, new ParseException("MCF temporary location not specified and default location "
                    + tempDir + " does not exist."));
            System.exit(3);
            return;
        }
    } else {
        tempDir = new File(sTempDir);
        if (!tempDir.isDirectory()) {
            printUsage(options, new ParseException("Specified temporary location does not exist."));
            System.exit(3);
            return;
        }
    }

    File mcfFile = new File(cl.getArgs()[0]);
    if (!mcfFile.isFile()) {
        printUsage(options, new ParseException("MCF input file does not exist."));
        System.exit(3);
        return;
    }
    mcfFile = mcfFile.getAbsoluteFile();

    File tempImages = new File(new File(System.getProperty("user.home")), ".mcf2pdf");
    if (cl.hasOption("w")) {
        tempImages = new File(cl.getOptionValue("w"));
        if (!tempImages.mkdirs() && !tempImages.isDirectory()) {
            printUsage(options,
                    new ParseException("Specified working dir does not exist and could not be created."));
            System.exit(3);
            return;
        }
    }

    int dpi = 150;
    if (cl.hasOption("r")) {
        try {
            dpi = Integer.valueOf(cl.getOptionValue("r")).intValue();
            if (dpi < 30 || dpi > 600)
                throw new IllegalArgumentException();
        } catch (Exception e) {
            printUsage(options,
                    new ParseException("Parameter for option -r must be an integer between 30 and 600."));
        }
    }

    int maxPageNo = -1;
    if (cl.hasOption("n")) {
        try {
            maxPageNo = Integer.valueOf(cl.getOptionValue("n")).intValue();
            if (maxPageNo < 0)
                throw new IllegalArgumentException();
        } catch (Exception e) {
            printUsage(options, new ParseException("Parameter for option -n must be an integer >= 0."));
        }
    }

    boolean binding = true;
    if (cl.hasOption("b")) {
        binding = false;
    }

    OutputStream finalOut;
    if (cl.getArgs()[1].equals("-"))
        finalOut = System.out;
    else {
        try {
            finalOut = new FileOutputStream(cl.getArgs()[1]);
        } catch (IOException e) {
            printUsage(options, new ParseException("Output file could not be created."));
            System.exit(3);
            return;
        }
    }

    // configure logging, if no system property is present
    if (System.getProperty("log4j.configuration") == null) {
        PropertyConfigurator.configure(Main.class.getClassLoader().getResource("log4j.properties"));

        Logger.getRootLogger().setLevel(Level.INFO);
        if (cl.hasOption("q"))
            Logger.getRootLogger().setLevel(Level.ERROR);
        if (cl.hasOption("d"))
            Logger.getRootLogger().setLevel(Level.DEBUG);
    }

    // start conversion to XSL-FO
    // if -x is specified, this is the only thing we do
    OutputStream xslFoOut;
    if (cl.hasOption("x"))
        xslFoOut = finalOut;
    else
        xslFoOut = new ByteArrayOutputStream();

    Log log = LogFactory.getLog(Main.class);

    try {
        new Mcf2FoConverter(installDir, tempDir, tempImages).convert(mcfFile, xslFoOut, dpi, binding,
                maxPageNo);
        xslFoOut.flush();

        if (!cl.hasOption("x")) {
            // convert to PDF
            log.debug("Converting XSL-FO data to PDF");
            byte[] data = ((ByteArrayOutputStream) xslFoOut).toByteArray();
            PdfUtil.convertFO2PDF(new ByteArrayInputStream(data), finalOut, dpi);
            finalOut.flush();
        }
    } catch (Exception e) {
        log.error("An exception has occured", e);
        System.exit(1);
        return;
    } finally {
        if (finalOut instanceof FileOutputStream) {
            try {
                finalOut.close();
            } catch (Exception e) {
            }
        }
    }
}

From source file:com.tmo.swagger.main.GenrateSwaggerJson.java

public static void main(String[] args)
        throws JsonGenerationException, JsonMappingException, IOException, EmptyXlsRows {

    PropertyReader pr = new PropertyReader();

    Properties prop = pr.readPropertiesFile(args[0]);
    //Properties prop =pr.readClassPathPropertyFile("common.properties");
    String swaggerFile = prop.getProperty("swagger.json");
    String sw = "";
    if (swaggerFile != null && swaggerFile.length() > 0) {
        Swagger swagger = populatePropertiesOnlyPaths(prop, new SwaggerParser().read(swaggerFile));
        ObjectMapper mapper = new ObjectMapper();
        mapper.setSerializationInclusion(Include.NON_NULL);
        sw = mapper.writeValueAsString(swagger);
    } else {/* w w w .  j  a v a  2  s  . c  om*/
        ObjectMapper mapper = new ObjectMapper();
        mapper.setSerializationInclusion(Include.NON_NULL);
        Swagger swagger = populateProperties(prop);
        sw = mapper.writeValueAsString(swagger);
    }
    try {
        File file = new File(args[1] + prop.getProperty("path.operation.tags") + ".json");
        //File file = new File("src/main/resources/"+prop.getProperty("path.operation.tags")+".json");
        if (!file.exists()) {
            file.createNewFile();
        }
        FileWriter fw = new FileWriter(file.getAbsoluteFile());
        BufferedWriter bw = new BufferedWriter(fw);
        bw.write(sw);
        logger.info("Swagger Genration Done!");
        bw.close();
    } catch (IOException e) {
        e.printStackTrace();
    }
}

From source file:TwitterClustering.java

public static void main(String[] args) throws FileNotFoundException, IOException {
    // TODO code application logic here

    File outFile = new File(args[3]);
    Scanner s = new Scanner(new File(args[1])).useDelimiter(",");
    JSONParser parser = new JSONParser();
    Set<Cluster> clusterSet = new HashSet<Cluster>();
    HashMap<String, Tweet> tweets = new HashMap();
    FileWriter fw = new FileWriter(outFile.getAbsoluteFile());
    BufferedWriter bw = new BufferedWriter(fw);

    // init/*from  ww  w .jav a  2 s  . c o  m*/
    try {

        Object obj = parser.parse(new FileReader(args[2]));

        JSONArray jsonArray = (JSONArray) obj;

        for (int i = 0; i < jsonArray.size(); i++) {

            Tweet twt = new Tweet();
            JSONObject jObj = (JSONObject) jsonArray.get(i);
            String text = jObj.get("text").toString();

            long sum = 0;
            for (int y = 0; y < text.toCharArray().length; y++) {

                sum += (int) text.toCharArray()[y];
            }

            String[] token = text.split(" ");
            String tID = jObj.get("id").toString();

            Set<String> mySet = new HashSet<String>(Arrays.asList(token));
            twt.setAttributeValue(sum);
            twt.setText(mySet);
            twt.setTweetID(tID);
            tweets.put(tID, twt);

        }

        // preparing initial clusters
        int i = 0;
        while (s.hasNext()) {
            String id = s.next();// id
            Tweet t = tweets.get(id.trim());
            clusterSet.add(new Cluster(i + 1, t, new LinkedList()));
            i++;
        }

        Iterator it = tweets.entrySet().iterator();

        for (int l = 0; l < 2; l++) { // limit to 25 iterations

            while (it.hasNext()) {
                Map.Entry me = (Map.Entry) it.next();

                // calculate distance to each centroid
                Tweet p = (Tweet) me.getValue();
                HashMap<Cluster, Float> distMap = new HashMap();

                for (Cluster clust : clusterSet) {

                    distMap.put(clust, jaccardDistance(p.getText(), clust.getCentroid().getText()));
                }

                HashMap<Cluster, Float> sorted = (HashMap<Cluster, Float>) sortByValue(distMap);

                sorted.keySet().iterator().next().getMembers().add(p);

            }

            // calculate new centroid and update Clusterset
            for (Cluster clust : clusterSet) {

                TreeMap<String, Long> tDistMap = new TreeMap();

                Tweet newCentroid = null;
                Long avgSumDist = new Long(0);
                for (int j = 0; j < clust.getMembers().size(); j++) {

                    avgSumDist += clust.getMembers().get(j).getAttributeValue();
                    tDistMap.put(clust.getMembers().get(j).getTweetID(),
                            clust.getMembers().get(j).getAttributeValue());
                }
                if (clust.getMembers().size() != 0) {
                    avgSumDist /= (clust.getMembers().size());
                }

                ArrayList<Long> listValues = new ArrayList<Long>(tDistMap.values());

                if (tDistMap.containsValue(findClosestNumber(listValues, avgSumDist))) {
                    // found closest
                    newCentroid = tweets
                            .get(getKeyByValue(tDistMap, findClosestNumber(listValues, avgSumDist)));
                    clust.setCentroid(newCentroid);
                }

            }

        }
        // create an iterator
        Iterator iterator = clusterSet.iterator();

        // check values
        while (iterator.hasNext()) {

            Cluster c = (Cluster) iterator.next();
            bw.write(c.getId() + "\t");
            System.out.print(c.getId() + "\t");

            for (Tweet t : c.getMembers()) {
                bw.write(t.getTweetID() + ", ");
                System.out.print(t.getTweetID() + ",");

            }
            bw.write("\n");
            System.out.println("");
        }

        System.out.println("");

        System.out.println("SSE " + sumSquaredErrror(clusterSet));

    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        bw.close();
        fw.close();
    }
}

From source file:edu.uci.ics.asterix.transaction.management.service.locking.LockManagerRandomUnitTest.java

public static void main(String args[]) throws ACIDException, AsterixException, IOException {
    int i;/*from  w  w  w  .  j a va 2  s  .c om*/
    //prepare configuration file
    File cwd = new File(System.getProperty("user.dir"));
    File asterixdbDir = cwd.getParentFile();
    File srcFile = new File(asterixdbDir.getAbsoluteFile(),
            "asterix-app/src/main/resources/asterix-build-configuration.xml");
    File destFile = new File(cwd, "target/classes/asterix-configuration.xml");
    FileUtils.copyFile(srcFile, destFile);

    TransactionSubsystem txnProvider = new TransactionSubsystem("nc1", null,
            new AsterixTransactionProperties(new AsterixPropertiesAccessor()));
    rand = new Random(System.currentTimeMillis());
    for (i = 0; i < MAX_NUM_OF_ENTITY_LOCK_JOB; i++) {
        System.out.println("Creating " + i + "th EntityLockJob..");
        generateEntityLockThread(txnProvider);
    }

    for (i = 0; i < MAX_NUM_OF_DATASET_LOCK_JOB; i++) {
        System.out.println("Creating " + i + "th DatasetLockJob..");
        generateDatasetLockThread(txnProvider);
    }

    for (i = 0; i < MAX_NUM_OF_UPGRADE_JOB; i++) {
        System.out.println("Creating " + i + "th EntityLockUpgradeJob..");
        generateEntityLockUpgradeThread(txnProvider);
    }
    ((LogManager) txnProvider.getLogManager()).stop(false, null);
}

From source file:edu.uci.ics.asterix.transaction.management.service.locking.LockManagerDeterministicUnitTest.java

public static void main(String args[]) throws ACIDException, IOException, AsterixException {
    //prepare configuration file
    File cwd = new File(System.getProperty("user.dir"));
    File asterixdbDir = cwd.getParentFile();
    File srcFile = new File(asterixdbDir.getAbsoluteFile(),
            "asterix-app/src/main/resources/asterix-build-configuration.xml");
    File destFile = new File(cwd, "target/classes/asterix-configuration.xml");
    FileUtils.copyFile(srcFile, destFile);

    //initialize controller thread
    String requestFileName = new String(
            "src/main/java/edu/uci/ics/asterix/transaction/management/service/locking/LockRequestFile");
    Thread t = new Thread(new LockRequestController(requestFileName));
    t.start();//from  w w  w  . j a v  a2 s . com
}

From source file:de.uni_koblenz.jgralab.utilities.tgraphbrowser.TGraphBrowserServer.java

/**
 * Runs the server. Needed args: -w --workspace the workspace
 * //from  ww  w .  j  a  v a 2 s .c  o  m
 * @param args
 */
public static void main(String[] args) {
    CommandLine comLine = processCommandLineOptions(args);
    assert comLine != null;
    try {
        starttime = System.currentTimeMillis();
        String portnumber = comLine.getOptionValue("p");
        String workspacePath;

        if (comLine.hasOption("r")) {
            TwoDVisualizer.PRINT_ROLE_NAMES = true;
        }

        if (comLine.hasOption("w")) {
            workspacePath = comLine.getOptionValue("w");
        } else {
            File workspace = new File(System.getProperty("java.io.tmpdir") + File.separator + "tgraphbrowser");
            if (!workspace.exists()) {
                if (!workspace.mkdir()) {
                    logger.info("The temp folder " + workspace.getAbsolutePath() + " could not be created.");
                }
            }
            workspace = new File(workspace.getAbsoluteFile() + File.separator + "workspace");
            if (!workspace.exists()) {
                if (!workspace.mkdir()) {
                    logger.info(
                            "The default workspace " + workspace.getAbsolutePath() + " could not be created.");
                }
            }
            workspacePath = workspace.getAbsolutePath();
        }
        new TGraphBrowserServer(portnumber == null ? DEFAULT_PORT : Integer.parseInt(portnumber), workspacePath,
                comLine.getOptionValue("m"), comLine.getOptionValue("s")).start();
        if (comLine.getOptionValue("ic") != null) {
            TabularVisualizer.NUMBER_OF_INCIDENCES_PER_PAGE = Math
                    .max(Integer.parseInt(comLine.getOptionValue("ic")), 1);
        }
        if (comLine.hasOption("d")) {
            StateRepository.dot = comLine.getOptionValue("d");
        } else {
            System.out.println("The 2D-Visualization is disabled because parameter -d is not set.");
        }
        String timeout = comLine.getOptionValue("t");
        String checkIntervall = comLine.getOptionValue("i");
        new DeleteUnusedStates(timeout == null ? 600 : Integer.parseInt(timeout),
                checkIntervall == null ? 60 : Integer.parseInt(checkIntervall)).start();
        if (comLine.hasOption("td")) {
            TwoDVisualizer.SECONDS_TO_WAIT_FOR_DOT = Integer.parseInt(comLine.getOptionValue("td"));
        }
    } catch (IOException e) {
        System.out.println(e);
    }
}