List of usage examples for java.util Timer schedule
public void schedule(TimerTask task, Date firstTime, long period)
From source file:org.wattdepot.client.http.api.performance.GetEarliestValueThroughput.java
/** * @param args command line arguments -s <server uri> -u <username> -p * <password> -o <orgId> -n <numSamples> [-d]. * @throws BadSensorUriException if there is a problem with the WattDepot * sensor definition.//from w w w .j a v a 2 s . c o m * @throws IdNotFoundException if there is a problem with the organization id. * @throws BadCredentialException if the credentials are not valid. */ public static void main(String[] args) throws BadCredentialException, IdNotFoundException, BadSensorUriException { Options options = new Options(); CommandLine cmd = null; String serverUri = null; String username = null; String organizationId = null; String password = null; Integer numSamples = null; boolean debug = false; options.addOption("h", false, "Usage: FindMeasurementThroughput -s <server uri> -u <username>" + " -p <password> -o <orgId> [-d]"); options.addOption("s", "server", true, "WattDepot Server URI. (http://server.wattdepot.org)"); options.addOption("u", "username", true, "Username"); options.addOption("o", "organizationId", true, "User's Organization id."); options.addOption("p", "password", true, "Password"); options.addOption("n", "numSamples", true, "Number of puts to sample."); options.addOption("d", "debug", false, "Displays statistics as the Measurements are stored."); CommandLineParser parser = new PosixParser(); HelpFormatter formatter = new HelpFormatter(); try { cmd = parser.parse(options, args); } catch (ParseException e) { System.err.println("Command line parsing failed. Reason: " + e.getMessage() + ". Exiting."); System.exit(1); } if (cmd.hasOption("h")) { formatter.printHelp("GetEarliestValueThroughput", options); System.exit(0); } if (cmd.hasOption("s")) { serverUri = cmd.getOptionValue("s"); } else { serverUri = "http://server.wattdepot.org/"; } if (cmd.hasOption("u")) { username = cmd.getOptionValue("u"); } else { username = "user"; } if (cmd.hasOption("p")) { password = cmd.getOptionValue("p"); } else { password = "default"; } if (cmd.hasOption("o")) { organizationId = cmd.getOptionValue("o"); } else { organizationId = "organization"; } if (cmd.hasOption("n")) { numSamples = Integer.parseInt(cmd.getOptionValue("n")); } else { numSamples = 13; } debug = cmd.hasOption("d"); if (debug) { System.out.println("GetEarliestValue Throughput:"); System.out.println(" WattDepotServer: " + serverUri); System.out.println(" Username: " + username); System.out.println(" OrganizationId: " + organizationId); System.out.println(" Password: ********"); System.out.println(" Samples: " + numSamples); } Timer t = new Timer("monitoring"); t.schedule(new GetEarliestValueThroughput(serverUri, username, organizationId, password, debug), 0, numSamples * 1000); }
From source file:org.wattdepot.client.http.api.performance.GetIntervalValueThroughput.java
/** * @param args command line arguments -s <server uri> -u <username> -p * <password> -o <orgId> -n <numSamples> [-d]. * @throws BadSensorUriException if there is a problem with the WattDepot * sensor definition./*from w w w . ja v a 2s .c om*/ * @throws IdNotFoundException if there is a problem with the organization id. * @throws BadCredentialException if the credentials are not valid. */ public static void main(String[] args) throws BadCredentialException, IdNotFoundException, BadSensorUriException { Options options = new Options(); CommandLine cmd = null; String serverUri = null; String username = null; String organizationId = null; String password = null; Integer numSamples = null; boolean debug = false; options.addOption("h", false, "Usage: GetIntervalValueThroughput -s <server uri> -u <username>" + " -p <password> -o <orgId> [-d]"); options.addOption("s", "server", true, "WattDepot Server URI. (http://server.wattdepot.org)"); options.addOption("u", "username", true, "Username"); options.addOption("o", "organizationId", true, "User's Organization id."); options.addOption("p", "password", true, "Password"); options.addOption("n", "numSamples", true, "Number of puts to sample."); options.addOption("d", "debug", false, "Displays statistics as the Gets are made."); CommandLineParser parser = new PosixParser(); HelpFormatter formatter = new HelpFormatter(); try { cmd = parser.parse(options, args); } catch (ParseException e) { System.err.println("Command line parsing failed. Reason: " + e.getMessage() + ". Exiting."); System.exit(1); } if (cmd.hasOption("h")) { formatter.printHelp("GetIntervalValueThroughput", options); System.exit(0); } if (cmd.hasOption("s")) { serverUri = cmd.getOptionValue("s"); } else { serverUri = "http://server.wattdepot.org/"; } if (cmd.hasOption("u")) { username = cmd.getOptionValue("u"); } else { username = "user"; } if (cmd.hasOption("p")) { password = cmd.getOptionValue("p"); } else { password = "default"; } if (cmd.hasOption("o")) { organizationId = cmd.getOptionValue("o"); } else { organizationId = "organization"; } if (cmd.hasOption("n")) { numSamples = Integer.parseInt(cmd.getOptionValue("n")); } else { numSamples = 13; } debug = cmd.hasOption("d"); if (debug) { System.out.println("GetLatestValue Throughput:"); System.out.println(" WattDepotServer: " + serverUri); System.out.println(" Username: " + username); System.out.println(" OrganizationId: " + organizationId); System.out.println(" Password: ********"); System.out.println(" Samples: " + numSamples); } Timer t = new Timer("monitoring"); t.schedule(new GetIntervalValueThroughput(serverUri, username, organizationId, password, debug), 0, numSamples * 1000); }
From source file:org.wattdepot.client.http.api.performance.GetLatestValueThroughput.java
/** * @param args command line arguments -s <server uri> -u <username> -p * <password> -o <orgId> -n <numSamples> [-d]. * @throws BadSensorUriException if there is a problem with the WattDepot * sensor definition.//from w w w . j ava 2 s .c o m * @throws IdNotFoundException if there is a problem with the organization id. * @throws BadCredentialException if the credentials are not valid. */ public static void main(String[] args) throws BadCredentialException, IdNotFoundException, BadSensorUriException { Options options = new Options(); CommandLine cmd = null; String serverUri = null; String username = null; String organizationId = null; String password = null; Integer numSamples = null; boolean debug = false; options.addOption("h", false, "Usage: GetLatestValueThroughput -s <server uri> -u <username>" + " -p <password> -o <orgId> [-d]"); options.addOption("s", "server", true, "WattDepot Server URI. (http://server.wattdepot.org)"); options.addOption("u", "username", true, "Username"); options.addOption("o", "organizationId", true, "User's Organization id."); options.addOption("p", "password", true, "Password"); options.addOption("n", "numSamples", true, "Number of puts to sample."); options.addOption("d", "debug", false, "Displays statistics as the Gets are made."); CommandLineParser parser = new PosixParser(); HelpFormatter formatter = new HelpFormatter(); try { cmd = parser.parse(options, args); } catch (ParseException e) { System.err.println("Command line parsing failed. Reason: " + e.getMessage() + ". Exiting."); System.exit(1); } if (cmd.hasOption("h")) { formatter.printHelp("GetLatestValueThroughput", options); System.exit(0); } if (cmd.hasOption("s")) { serverUri = cmd.getOptionValue("s"); } else { serverUri = "http://server.wattdepot.org/"; } if (cmd.hasOption("u")) { username = cmd.getOptionValue("u"); } else { username = "user"; } if (cmd.hasOption("p")) { password = cmd.getOptionValue("p"); } else { password = "default"; } if (cmd.hasOption("o")) { organizationId = cmd.getOptionValue("o"); } else { organizationId = "organization"; } if (cmd.hasOption("n")) { numSamples = Integer.parseInt(cmd.getOptionValue("n")); } else { numSamples = 13; } debug = cmd.hasOption("d"); if (debug) { System.out.println("GetLatestValue Throughput:"); System.out.println(" WattDepotServer: " + serverUri); System.out.println(" Username: " + username); System.out.println(" OrganizationId: " + organizationId); System.out.println(" Password: ********"); System.out.println(" Samples: " + numSamples); } Timer t = new Timer("monitoring"); t.schedule(new GetLatestValueThroughput(serverUri, username, organizationId, password, debug), 0, numSamples * 1000); }
From source file:jp.mamesoft.mailsocketchat.Mailsocketchat.java
public static void main(String argv[]) { System.out.println("MailSocketChat Ver." + version); if (argv.length != 6) { System.out.println(/*w w w . j a v a2 s . com*/ "ERROR! ? <?URL> <???> <GMail??> <GMail> <(Simple???Normal???All)> <????(Subject???Text)> ???????"); System.exit(0); } TimerTask newversion = new NewVersion(); Timer timer = new Timer(); timer.schedule(newversion, 0, 6 * 60 * 60 * 1000); //6?????? chat_url = argv[0]; chat_name = argv[1]; mail_user = argv[2]; mail_pass = argv[3]; if (argv[4].equals("Simple")) { logformat = "simple"; } else if (argv[4].equals("Normal")) { logformat = "normal"; } else if (argv[4].equals("All")) { logformat = "all"; } else { System.out.println( "ERROR! (5)???????Simple???Normal???All???????"); System.exit(0); } if (argv[5].equals("Subject")) { subjectname = true; } else if (argv[5].equals("Text")) { subjectname = false; } else { System.out.println( "ERROR! ????(6)???????Subject???Text???????"); System.exit(0); } try { Properties headers = new Properties(); headers.setProperty("user-agent", "MailSocketChat/" + version + " (" + osName + " " + osVer + ") Java/" + javaver + " (Mamesoft Web)"); socket = new SocketIO(chat_url, headers); socket.connect(new IOCallback() { @Override public void onMessage(JSONObject json, IOAcknowledge ack) { try { } catch (JSONException e) { e.printStackTrace(); } } @Override public void onMessage(String data, IOAcknowledge ack) { } @Override public void onError(SocketIOException socketIOException) { System.out.println("??????"); System.err.println(socketIOException); System.exit(0); } @Override public void onDisconnect() { System.out.println("???????"); System.exit(0); } @Override public void onConnect() { socket.emit("register", new JSONObject().put("mode", "client").put("lastid", 1)); System.out.println("SocketChat?????"); Thread mail = new Mail(); mail.start(); } @Override public void on(String event, IOAcknowledge ack, Object... args) { if (event.equals("log")) { JSONObject jsondata = (JSONObject) args[0]; Logperse(jsondata); } if (event.equals("init")) { JSONObject jsondata = (JSONObject) args[0]; JSONArray logs = jsondata.getJSONArray("logs"); for (int i = logs.length() - 1; i >= 0; i--) { JSONObject log = logs.getJSONObject(i); Logperse(log); } socket.emit("inout", new JSONObject().put("name", chat_name)); } if (event.equals("result")) { JSONObject jsondata = (JSONObject) args[0]; System.out.println(jsondata); } if (event.equals("users")) { JSONObject jsondata = (JSONObject) args[0]; JSONArray users = jsondata.getJSONArray("users"); for (int i = 0; i < users.length(); i++) { JSONObject user = users.getJSONObject(i); userchange(user); } } if (event.equals("newuser")) { JSONObject jsondata = (JSONObject) args[0]; userchange(jsondata); } if (event.equals("inout")) { JSONObject jsondata = (JSONObject) args[0]; userchange(jsondata); } if (event.equals("deluser")) { Integer id = (Integer) args[0]; if (users.containsKey(id)) { users.remove(id); } if (roms.containsKey(id)) { roms.remove(id); } } if (event.equals("userinfo")) { JSONObject jsondata = (JSONObject) args[0]; if (jsondata.getBoolean("rom")) { in = false; } else { in = true; } } } }); } catch (MalformedURLException e1) { e1.printStackTrace(); System.out.println("URL????????"); return; } }
From source file:Mulai.java
public static void main(String[] args) { //System.out.println("user ID: "+args[0]); //System.out.println("things ID: "+args[1]); //new Gateway(args[0],args[1]); Timer timer = new Timer(); timer.schedule(new Gateway(), 0, 10000); }
From source file:JTop.java
public static void main(String[] args) throws Exception { // Validate the input arguments if (args.length != 1) { usage();/* ww w .ja va2 s . c o m*/ } String[] arg2 = args[0].split(":"); if (arg2.length != 2) { usage(); } String hostname = arg2[0]; int port = -1; try { port = Integer.parseInt(arg2[1]); } catch (NumberFormatException x) { usage(); } if (port < 0) { usage(); } // Create the JTop Panel final JTop jtop = new JTop(); // Set up the MBeanServerConnection to the target VM MBeanServerConnection server = connect(hostname, port); jtop.setMBeanServerConnection(server); // A timer task to update GUI per each interval TimerTask timerTask = new TimerTask() { public void run() { // Schedule the SwingWorker to update the GUI jtop.newSwingWorker().execute(); } }; // Create the standalone window with JTop panel // by the event dispatcher thread SwingUtilities.invokeAndWait(new Runnable() { public void run() { createAndShowGUI(jtop); } }); // refresh every 2 seconds Timer timer = new Timer("JTop Sampling thread"); timer.schedule(timerTask, 0, 2000); }
From source file:org.wattdepot.server.measurement.pruning.MeasurementPruner.java
/** * Processes the command line arguments and runs the * MeasurementGarbageCollector one time. * // w ww .ja v a 2 s . co m * @param args The command line arguments. * @throws Exception if there is a problem. */ public static void main(String[] args) throws Exception { Options options = new Options(); options.addOption("h", "help", false, "Usage: MeasurementPruner -o <orgId> -m <measurement pruning definition id>" + " [-d] [-s]"); options.addOption("o", "orgId", true, "Organization Id."); options.addOption("m", "mpd", true, "MeasurementPruningDefinition Id."); options.addOption("d", "debug", false, "Display debugging information."); options.addOption("s", "single", false, "Run gc only once, right away."); CommandLine cmd = null; String orgId = null; String gcdId = null; boolean debug = false; boolean single = false; CommandLineParser parser = new PosixParser(); HelpFormatter formatter = new HelpFormatter(); try { cmd = parser.parse(options, args); } catch (ParseException e) { System.err.println("Command line parsing failed. Reason: " + e.getMessage() + ". Exiting."); System.exit(1); } if (cmd.hasOption("h")) { formatter.printHelp("MeasurementGarbageCollector", options); System.exit(0); } if (cmd.hasOption("o")) { orgId = cmd.getOptionValue("o"); } else { orgId = Organization.ADMIN_GROUP.getId(); } if (cmd.hasOption("m")) { gcdId = cmd.getOptionValue("m"); } debug = cmd.hasOption("d"); single = cmd.hasOption("s"); if (debug) { System.out.println("Measurement Garbage Collection:"); System.out.println("Org Id = " + orgId); System.out.println("GCD Id = " + gcdId); System.out.println("Single run = " + single); } ServerProperties properties = new ServerProperties(); // if (debug) { // properties.set(ServerProperties.SERVER_TIMING_KEY, // ServerProperties.TRUE); // } MeasurementPruner mgc = new MeasurementPruner(properties, gcdId, orgId, debug); if (single) { mgc.pruneMeasurements(); } else { // Set up the TimerTask to run the gc at the right time. if (debug) { System.out.println("Setting up Timer for " + mgc); } Timer t = new Timer(); t.schedule(mgc, mgc.millisToNextRun(), mgc.getGCPeriod()); } }
From source file:org.wattdepot.client.http.api.collector.MeasurementSummaryClient.java
/** * @param args command line arguments.//www . j a va2 s .c o m */ public static void main(String[] args) { Options options = new Options(); options.addOption("h", false, "Usage: MeasurementSummaryClient -s <server uri> -u <username>" + " -p <password> -o <orgId> -c <collectorId> -m <millisecond sleep> [-d]"); options.addOption("s", "server", true, "WattDepot Server URI. (http://server.wattdepot.org)"); options.addOption("u", "username", true, "Username"); options.addOption("o", "organizationId", true, "User's Organization id."); options.addOption("p", "password", true, "Password"); options.addOption("c", "collector", true, "Collector Process Definition Id"); options.addOption("m", "milliseconds", true, "Number of milliseconds to sleep between polls."); options.addOption("d", "debug", false, "Displays sensor data as it is sent to the server."); options.addOption("w", "windowing", false, "Use a window instead of getting all the measurements."); CommandLine cmd = null; String serverUri = null; String username = null; String organizationId = null; String password = null; String collectorId = null; Integer milliSeconds = null; boolean debug = false; boolean windowP = false; CommandLineParser parser = new PosixParser(); HelpFormatter formatter = new HelpFormatter(); try { cmd = parser.parse(options, args); } catch (ParseException e) { System.err.println("Command line parsing failed. Reason: " + e.getMessage() + ". Exiting."); System.exit(1); } if (cmd.hasOption("h")) { formatter.printHelp("StressTestCollector", options); System.exit(0); } if (cmd.hasOption("s")) { serverUri = cmd.getOptionValue("s"); } else { serverUri = "http://server.wattdepot.org/"; } if (cmd.hasOption("u")) { username = cmd.getOptionValue("u"); } else { username = "user"; } if (cmd.hasOption("p")) { password = cmd.getOptionValue("p"); } else { password = "default"; } if (cmd.hasOption("o")) { organizationId = cmd.getOptionValue("o"); } else { organizationId = "organization"; } if (cmd.hasOption("c")) { collectorId = cmd.getOptionValue("c"); } else { collectorId = "stress_test"; } if (cmd.hasOption("m")) { milliSeconds = Integer.parseInt(cmd.getOptionValue("m")); } else { milliSeconds = 1000; } debug = cmd.hasOption("d"); windowP = cmd.hasOption("w"); if (debug) { System.out.println("Measurement Summary Client:"); System.out.println(" WattDepotServer: " + serverUri); System.out.println(" Username: " + username); System.out.println(" OrganizationId: " + organizationId); System.out.println(" Password :" + password); System.out.println(" CPD Id: " + collectorId); System.out.println(" MilliSeconds: " + milliSeconds); System.out.println(" Windowing: " + windowP); } Timer t = new Timer(); try { MeasurementSummaryClient c = new MeasurementSummaryClient(serverUri, username, organizationId, password, collectorId, debug); c.windowP = windowP; System.out.format("Started MeasurementSummaryClient at %s%n", Tstamp.makeTimestamp()); t.schedule(c, 0, milliSeconds); } catch (BadCredentialException e) { e.printStackTrace(); } catch (IdNotFoundException e) { e.printStackTrace(); } catch (BadSensorUriException e) { e.printStackTrace(); } }
From source file:org.wattdepot.client.http.api.collector.StressTestCollector.java
/** * @param args command line arguments.//w w w. j ava 2 s .c om */ public static void main(String[] args) { Options options = new Options(); options.addOption("h", false, "Usage: StressTestCollector -s <server uri> -u <username>" + " -p <password> -o <orgId> -c <collectorId> -n <num sim sensors> -m <millisecond sleep> [-d]"); options.addOption("s", "server", true, "WattDepot Server URI. (http://server.wattdepot.org)"); options.addOption("u", "username", true, "Username"); options.addOption("o", "organizationId", true, "User's Organization id."); options.addOption("p", "password", true, "Password"); options.addOption("c", "collector", true, "Collector Process Definition Id"); options.addOption("n", "numberOfSensors", true, "Number of Simulated Sensors"); options.addOption("m", "milliseconds", true, "Number of milliseconds to sleep between measurements."); options.addOption("d", "debug", false, "Displays sensor data as it is sent to the server."); CommandLine cmd = null; String serverUri = null; String username = null; String organizationId = null; String password = null; String collectorId = null; Integer numSensors = null; Integer milliSeconds = null; boolean debug = false; CommandLineParser parser = new PosixParser(); HelpFormatter formatter = new HelpFormatter(); try { cmd = parser.parse(options, args); } catch (ParseException e) { System.err.println("Command line parsing failed. Reason: " + e.getMessage() + ". Exiting."); System.exit(1); } if (cmd.hasOption("h")) { formatter.printHelp("StressTestCollector", options); System.exit(0); } if (cmd.hasOption("s")) { serverUri = cmd.getOptionValue("s"); } else { serverUri = "http://server.wattdepot.org/"; } if (cmd.hasOption("u")) { username = cmd.getOptionValue("u"); } else { username = "user"; } if (cmd.hasOption("p")) { password = cmd.getOptionValue("p"); } else { password = "default"; } if (cmd.hasOption("o")) { organizationId = cmd.getOptionValue("o"); } else { organizationId = "organization"; } if (cmd.hasOption("c")) { collectorId = cmd.getOptionValue("c"); } else { collectorId = "stress_test"; } if (cmd.hasOption("n")) { numSensors = Integer.parseInt(cmd.getOptionValue("n")); } else { numSensors = 10; } if (cmd.hasOption("m")) { milliSeconds = Integer.parseInt(cmd.getOptionValue("m")); } else { milliSeconds = 1000; } debug = cmd.hasOption("d"); if (debug) { System.out.println("Stress Test Collector:"); System.out.println(" WattDepotServer: " + serverUri); System.out.println(" Username: " + username); System.out.println(" OrganizationId: " + organizationId); System.out.println(" Password :" + password); System.out.println(" CPD Id: " + collectorId); System.out.println(" Num Sensors: " + numSensors); System.out.println(" MilliSeconds: " + milliSeconds); } for (int i = 0; i < numSensors; i++) { Timer t = new Timer(); try { StressTestCollector collector = new StressTestCollector(serverUri, username, organizationId, password, collectorId, debug); System.out.format("Started StressTestCollector at %s%n", Tstamp.makeTimestamp()); t.schedule(collector, 0, milliSeconds); Thread.sleep(1000 / numSensors); } catch (BadCredentialException e) { e.printStackTrace(); } catch (IdNotFoundException e) { e.printStackTrace(); } catch (BadSensorUriException e) { e.printStackTrace(); } catch (InterruptedException e) { e.printStackTrace(); } } }
From source file:ComputeNode.java
public static void main(String[] argv) { String fileservername = "localhost"; String id = null;/*from w w w. j a v a 2 s. co m*/ Double underLoad = null; Double overLoad = null; Double failProb = null; Double constantload = null; Pair<Double, Double> gaussian = null; String fileName = null; ArgumentHandler cli = new ArgumentHandler( "FileServer [-h] [collector address] [-u underload] " + "[-o overload] [-c constant_load|-g mean variance] " + "[-p fail_prob] [-f configfile]", "Bala Subrahmanyam Kambala, Daniel William DaCosta - " + "GPLv3 (http://www.gnu.org/copyleft/gpl.html)", ""); cli.addOption("h", "help", false, "Print this usage information."); cli.addOption("u", "underLoad", true, "Under load threshold"); cli.addOption("o", "overLoad", true, "Over load threshold"); cli.addOption("c", "constant", true, "Generate constant load"); cli.addOption("p", "probability", true, "Fail Probability(0-100)"); cli.addOption("f", "configfile", true, "The configuration file to read parameters from. " + "The default is " + defaultconf + ". " + "Command line arguments will override config file " + "arguments."); cli.addOption(OptionBuilder.withLongOpt("gaussian").hasArgs(2) .withDescription("Generate a gaussian probability model for load " + "simulation. The first parameter is the mean " + "and the second parameter is the variance.") .create('g')); // parse command line CommandLine commandLine = cli.parse(argv); if (commandLine.hasOption('h')) { cli.usage(""); System.exit(0); } if (commandLine.hasOption('u')) { // TODO : Ensure the number is within range underLoad = Double.parseDouble(commandLine.getOptionValue('u')); } if (commandLine.hasOption('o')) { // TODO : Ensure the number is within range overLoad = Double.parseDouble(commandLine.getOptionValue('o')); } if (commandLine.hasOption('p')) { // TODO : Ensure the number is within range failProb = Double.parseDouble(commandLine.getOptionValue('p')); } if (commandLine.hasOption('c')) { // TODO : Ensure the number is within range constantload = Double.parseDouble(commandLine.getOptionValue('c')); } if (commandLine.hasOption('g')) { // TODO : Ensure the number is within range gaussian = new Pair<Double, Double>(Double.parseDouble(commandLine.getOptionValues('g')[0]), Double.parseDouble(commandLine.getOptionValues('g')[1])); } // TODO: If these flags are no longer mutually exclusive this // code should be adjusted to account for whatever constraint are // needed. if ((constantload != null) && (gaussian != null)) { cli.usage("-g -c switches are mutually exclusive!\n"); System.exit(1); } if (commandLine.hasOption('f')) { fileName = commandLine.getOptionValue('f'); } if (commandLine.getArgs().length != 0) fileservername = commandLine.getArgs()[0]; System.out.println(argv); try { ComputeNode node = new ComputeNode(fileservername, underLoad, overLoad, failProb, constantload, gaussian, fileName); Naming.rebind("ComputeNode" + Integer.toString(node.getID()), node); // Scheduling heart beat message handler Timer t = new Timer(); HeartBeatHandler h = node.new HeartBeatHandler(); t.schedule(h, 0, 1 * 1000); } catch (ConnectException ce) { //lg.log(Level.SEVERE, "Server is not alive"); ce.printStackTrace(); } catch (Exception e) { //lg.log(Level.SEVERE, "Exception in file server"); e.printStackTrace(); } }