List of usage examples for java.lang Thread MAX_PRIORITY
int MAX_PRIORITY
To view the source code for java.lang Thread MAX_PRIORITY.
Click Source Link
From source file:io.mandrel.frontier.FrontierContainer.java
public FrontierContainer(Spider spider, Accumulators accumulators, Clients clients) { super(accumulators, spider, clients); context.setDefinition(spider);// w ww .j a v a 2s .com // Init stores MetadataStore metadatastore = spider.getStores().getMetadataStore().build(context); metadatastore.init(); MetadataStores.add(spider.getId(), metadatastore); // Init frontier frontier = spider.getFrontier().build(context); // Revisitor BasicThreadFactory threadFactory = new BasicThreadFactory.Builder() .namingPattern("frontier-" + spider.getId() + "-%d").daemon(true).priority(Thread.MAX_PRIORITY) .build(); executor = Executors.newFixedThreadPool(1, threadFactory); revisitor = new Revisitor(frontier, metadatastore); executor.submit(revisitor); current.set(ContainerStatus.INITIATED); }
From source file:at.ac.ait.ubicity.fileloader.FileLoader.java
/** * /* w ww . j a v a 2s .c o m*/ * @param _fileInfo A FileInformation object representing usage information on the file we are supposed to load: line count already ingested, last usage time... * @param _keySpace Cassandra key space into which to ingest * @param _host Cassandra host / server * @param _batchSize MutationBatch size * @throws Exception Shouldn't happen, although the Disruptor may throw an Exception under duress */ @SuppressWarnings("unchecked") public final static void load(final FileInformation _fileInfo, final String _keySpace, final String _host, final int _batchSize) throws Exception { if (!cassandraInitialized) { keySpace = AstyanaxInitializer.doInit("Test Cluster", _host, _keySpace); cassandraInitialized = true; } LongTimeStampSorter tsSorter = new LongTimeStampSorter(); Thread tTSSorter = new Thread(tsSorter); tTSSorter.setPriority(Thread.MAX_PRIORITY - 1); tTSSorter.setName("long timestamp sorter "); tTSSorter.start(); //get the log id from the file's URI final String log_id = _fileInfo.getURI().toString(); final MutationBatch batch = keySpace.prepareMutationBatch(); logger.info("got keyspace " + keySpace.getKeyspaceName() + " from Astyanax initializer"); final LineIterator onLines = FileUtils.lineIterator(new File(_fileInfo.getURI())); final ExecutorService exec = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors() * 2); ColumnFamily crawl_stats = null; AggregationJob aggregationJob = new AggregationJob(keySpace, crawl_stats); Thread tAggJob = new Thread(aggregationJob); tAggJob.setName("Monitrix loader / aggregation job "); tAggJob.setPriority(Thread.MIN_PRIORITY + 1); tAggJob.start(); logger.info("[FILELOADER] started aggregation job, ring buffer running"); final Disruptor<SingleLogLineAsString> disruptor = new Disruptor(SingleLogLineAsString.EVENT_FACTORY, (int) Math.pow(TWO, 17), exec); SingleLogLineAsStringEventHandler.batch = batch; SingleLogLineAsStringEventHandler.keySpace = keySpace; SingleLogLineAsStringEventHandler.batchSize = _batchSize; SingleLogLineAsStringEventHandler.LOG_ID = log_id; SingleLogLineAsStringEventHandler.tsSorter = tsSorter; SingleLogLineAsStringEventHandler.aggregationJob = aggregationJob; //The EventHandler contains the actual logic for ingesting final EventHandler<SingleLogLineAsString> handler = new SingleLogLineAsStringEventHandler(); disruptor.handleEventsWith(handler); //get our Aggregate job in place //we are almost ready to start final RingBuffer<SingleLogLineAsString> rb = disruptor.start(); int _lineCount = 0; long _start, _lapse; _start = System.nanoTime(); int _linesAlreadyProcessed = _fileInfo.getLineCount(); //cycle through the lines already processed while (_lineCount < _linesAlreadyProcessed) { onLines.nextLine(); _lineCount++; } //now get down to the work we actually must do, and fill the ring buffer logger.info("begin proccessing of file " + _fileInfo.getURI() + " @line #" + _lineCount); while (onLines.hasNext()) { final long _seq = rb.next(); final SingleLogLineAsString event = rb.get(_seq); event.setValue(onLines.nextLine()); rb.publish(_seq); _lineCount++; } _lapse = System.nanoTime() - _start; logger.info("ended proccessing of file " + _fileInfo.getURI() + " @line #" + _lineCount); //stop, waiting for last threads still busy to finish their work disruptor.shutdown(); //update the file info, this will land in the cache _fileInfo.setLineCount(_lineCount); _fileInfo.setLastAccess(System.currentTimeMillis()); int _usageCount = _fileInfo.getUsageCount(); _fileInfo.setUsageCount(_usageCount++); //make sure we release resources onLines.close(); logger.info( "handled " + (_lineCount - _linesAlreadyProcessed) + " log lines in " + _lapse + " nanoseconds"); //now go to aggregation step SortedSet<Long> timeStamps = new TreeSet(tsSorter.timeStamps); long _minTs = timeStamps.first(); long _maxTs = timeStamps.last(); logger.info("**** min TimeStamp = " + _minTs); logger.info("**** max TimeStamp = " + _maxTs); StatsTableActualizer.update(_fileInfo.getURI().toString(), _minTs, _maxTs, _lineCount); // AggregationJob aggJob = new AggregationJob( keySpace, _host, _batchSize ); // Thread tAgg = new Thread( aggJob ); // tAgg.setName( "aggregation job " ); // tAgg.setPriority( Thread.MAX_PRIORITY - 1 ); // tAgg.start(); }
From source file:net.sf.cindy.impl.SimpleEventGenerator.java
public void setPriority(int priority) throws IllegalArgumentException { if (priority < Thread.MIN_PRIORITY || priority > Thread.MAX_PRIORITY) throw new IllegalArgumentException(); if (thread != null) thread.setPriority(priority);/* ww w .j a v a2s .c om*/ this.priority = priority; }
From source file:screancasttest.SenderAsyncTask.java
/** application context. */ @Override//from w ww . j a v a2s.c o m protected Void doInBackground(Void... params) { Thread.currentThread().setPriority(Thread.MAX_PRIORITY); String classget = LoginActivity.studClass; List<NameValuePair> params1 = new ArrayList<NameValuePair>(); params1.add(new BasicNameValuePair("class", classget)); String url = "http://176.32.230.250/anshuli.com/ScreenCast/getIPs.php"; json1 = jparser1.makeHttpRequest(url, "POST", params1); try { // Checking for SUCCESS TAG //forjson.clear(); String heading = ""; String message = ""; //Toast.makeText(MainActivity.this, (CharSequence) json, 1).show(); ipArray = new ArrayList<String>(); JSONArray account = json1.getJSONArray("IPs"); for (int i = 0; i < account.length(); i++) { json1 = account.getJSONObject(i); String IpString = json1.getString("IP"); if (!IpString.equals("0.0.0.0")) ipArray.add(IpString); // forjson.add(Roll+"-"+ NAME); //categories_description.add(description); } } catch (Exception e) { e.printStackTrace(); } String portget = LoginActivity.portget; int port = Integer.parseInt(portget); java.net.Socket socket = null; // ip.add("192.168.15.105"); // ip.add("192.168.15.103"); int len = ipArray.size(); /* try { for(int i=0;i<ip.size();i++) socket[i] = new java.net.Socket(ip.get(i),port); // socket1 = new java.net.Socket("192.168.15.105", port); // connect to server } catch (IOException e) { e.printStackTrace(); }*/ dataOut = new DataOutputStream[len]; try { for (int i = 0; i < len; i++) { socket = new java.net.Socket(ipArray.get(i), port); dataOut[i] = new DataOutputStream(socket.getOutputStream()); } // dataOut1 = new DataOutputStream(socket1.getOutputStream()); } catch (IOException e) { e.printStackTrace(); } while (!isCancelled()) { VideoChunk chunk = null; try { //Log.d(LOG_TAG, "waiting for data to send"); chunk = mVideoChunks.takeLast(); //Log.d(LOG_TAG,"got data. writing to socket"); int length = chunk.getData().length; for (int i = 0; i < ipArray.size(); i++) { dataOut[i].writeInt(length); dataOut[i].writeInt(chunk.getFlags()); dataOut[i].writeLong(chunk.getTimeUs()); dataOut[i].write(chunk.getData()); dataOut[i].flush(); } } catch (InterruptedException e) { e.printStackTrace(); continue; } catch (IOException e) { e.printStackTrace(); } } return null; }
From source file:unikn.dbis.univis.explorer.VSplashScreen.java
/** * Erzeugt eine neue <code>VSplashScreen</code> und sobald das Splashable gesetzt wurde * beendet sich die Screen von selbst.//from w ww . j a v a 2 s .c om * * @param inputStream Der Dateiname incl. des relativen Pfades des anzuzeigenden Images. */ public VSplashScreen(InputStream inputStream) { // Splash screen have to be always on top until the explorer // isn't loaded. setAlwaysOnTop(true); try { image = ImageIO.read(inputStream); } catch (IOException ioe) { ioe.printStackTrace(); } MediaTracker mt = new MediaTracker(this); mt.addImage(image, 0); try { mt.waitForAll(); } catch (InterruptedException e) { if (LOG.isErrorEnabled()) { LOG.error(e.getMessage(), e); } } thread = new Thread(this); thread.setPriority(Thread.MAX_PRIORITY); thread.start(); center(); setVisible(true); }
From source file:org.apache.axis2.clustering.control.wka.RpcMembershipRequestHandler.java
public Serializable replyRequest(Serializable msg, Member sender) { String domain = new String(sender.getDomain()); if (log.isDebugEnabled()) { log.debug("Membership request received by RpcMembershipRequestHandler for domain " + domain); log.debug("local domain: " + new String(membershipManager.getDomain())); }//from ww w. jav a 2s . c o m if (msg instanceof JoinGroupCommand) { log.info("Received JOIN message from " + TribesUtil.getName(sender)); // process this join request - handing this job over to a new thread, // since the reply doesn't need to contain the member we're just going to // add. Thread th = new Thread(new ProcessJoinCommand(sender)); th.setPriority(Thread.MAX_PRIORITY); th.start(); // Return the list of current members to the caller MemberListCommand memListCmd = new MemberListCommand(); memListCmd.setMembers(membershipManager.getMembers()); if (log.isDebugEnabled()) { log.debug("Sent MEMBER_LIST to " + TribesUtil.getName(sender)); } return memListCmd; } else if (msg instanceof MemberJoinedCommand) { log.info("Received MEMBER_JOINED message from " + TribesUtil.getName(sender)); MemberJoinedCommand command = (MemberJoinedCommand) msg; if (log.isDebugEnabled()) { log.debug(command); } try { command.setMembershipManager(membershipManager); command.execute(null); } catch (ClusteringFault e) { String errMsg = "Cannot handle MEMBER_JOINED notification"; log.error(errMsg, e); throw new RemoteProcessException(errMsg, e); } } else if (msg instanceof MemberListCommand) { try { //TODO: What if we receive more than one member list message? log.info("Received MEMBER_LIST message from " + TribesUtil.getName(sender)); MemberListCommand command = (MemberListCommand) msg; command.setMembershipManager(membershipManager); command.execute(null); return "Processed MEMBER_LIST message"; //TODO Send MEMBER_JOINED messages to all nodes } catch (ClusteringFault e) { String errMsg = "Cannot handle MEMBER_LIST message from " + TribesUtil.getName(sender); log.error(errMsg, e); throw new RemoteProcessException(errMsg, e); } } return null; }
From source file:rems.Program.java
/** * @param args the command line arguments *///w w w.j a v a 2 s . c om public static void main(String[] args) { try { Global.UsrsOrg_ID = 3; Global.dataBasDir = "C:\\1_DESIGNS\\MYAPPS\\Enterprise_Management_System\\Enterprise_Management_System\\bin\\Debug\\Images\\test_database"; Global.rnnrsBasDir = "C:\\1_DESIGNS\\MYAPPS\\Enterprise_Management_System\\Enterprise_Management_System\\bin\\Debug\\bin"; String pname = ManagementFactory.getRuntimeMXBean().getName(); if (pname.contains("@")) { Global.pid = Integer.parseInt(pname.substring(0, pname.lastIndexOf("@"))); } else { Global.pid = Thread.currentThread().getId(); } Global.HostOSNme = System.getProperty("os.name"); System.out.println(Global.pid); System.out.println(Global.HostOSNme); String[] macDet = Global.getMachDetails(); System.out.println(Arrays.toString(macDet)); System.out.println(args.length); System.out.println(Arrays.toString(args)); Global.errorLog += Global.pid + System.getProperty("line.separator") + Global.HostOSNme + System.getProperty("line.separator") + Arrays.toString(Global.getMachDetails()) + System.getProperty("line.separator"); //Global.writeToLog(); if (args.length >= 8) { Global.rnnrsBasDir = StringUtils.strip(args[7], "\""); runnerName = StringUtils.strip(args[5], "\""); Global.errorLog = args[0] + System.getProperty("line.separator") + args[1] + System.getProperty("line.separator") + args[2] + System.getProperty("line.separator") + "********************" + System.getProperty("line.separator") + args[4] + System.getProperty("line.separator") + args[5] + System.getProperty("line.separator") + args[6] + System.getProperty("line.separator") + Global.rnnrsBasDir + System.getProperty("line.separator"); if (args.length >= 10) { Global.callngAppType = StringUtils.strip(args[8], "\""); Global.dataBasDir = StringUtils.strip(args[9], "\""); Global.errorLog += args[8] + System.getProperty("line.separator") + args[9] + System.getProperty("line.separator"); if (args.length == 11) { Global.AppUrl = StringUtils.strip(args[10], "\""); Global.errorLog += args[10] + System.getProperty("line.separator"); } } Global.errorLog += "PID: " + Global.pid + " Running on: " + macDet[0] + " / " + macDet[1] + " / " + macDet[2]; Global.writeToLog(); Global.runID = Long.valueOf(args[6]); do_connection(args[0], args[1], args[2], args[3], args[4]); Global.appStatPath = Global.rnnrsBasDir; //Program.updateRates("2015-07-02"); if (Global.runID > 0) { Global.rnUser_ID = Long.valueOf( Global.getGnrlRecNm("rpt.rpt_report_runs", "rpt_run_id", "run_by", Global.runID)); Global.UsrsOrg_ID = Global.getUsrOrgID(Global.rnUser_ID); } if (!Global.globalSQLConn.isClosed()) { Global.globalSQLConn.close(); boolean isLstnrRnng = false; if (Program.runnerName.equals("REQUESTS LISTENER PROGRAM")) { int isIPAllwd = Global.getEnbldPssblValID(macDet[2], Global.getEnbldLovID("Allowed IP Address for Request Listener")); int isDBAllwd = Global.getEnbldPssblValID(Global.Dbase, Global.getEnbldLovID("Allowed DB Name for Request Listener")); if (isIPAllwd <= 0 || isDBAllwd <= 0) { Program.killThreads(); Thread.currentThread().interrupt(); //Program.killThreads(); return; } isLstnrRnng = Global.isRunnrRnng(Program.runnerName); if (isLstnrRnng == true) { Program.killThreads(); Thread.currentThread().interrupt(); //Program.killThreads(); return; } } Global.errorLog = "Successfully Connected to Database\r\n" + String.valueOf(isLstnrRnng) + System.getProperty("line.separator"); Global.writeToLog(); String rnnPryty = Global.getGnrlRecNm("rpt.rpt_prcss_rnnrs", "rnnr_name", "crnt_rnng_priority", Program.runnerName); if (isLstnrRnng == false && Program.runnerName.equals("REQUESTS LISTENER PROGRAM")) { Global.updatePrcsRnnrCmd(Program.runnerName, "0", -1); thread1 = new RqstLstnrUpdtrfunc("ThreadOne"); thread1.setDaemon(true); thread1.setName("ThreadOne"); thread1.setPriority(Thread.MIN_PRIORITY); //System.out.println("Starting ThreadOne thread..."); thread1.start(); Global.minimizeMemory(); if (Program.runnerName.equals("REQUESTS LISTENER PROGRAM")) { //Thread for Generating Run Requests for Scheduled Programs/Reports thread2 = new GnrtSchldRnsfunc("ThreadTwo"); thread2.setDaemon(true); thread2.setName("ThreadTwo"); thread2.setPriority(Thread.MIN_PRIORITY); //System.out.println("Starting ThreadTwo thread..."); thread2.start(); //Thread for Generating Run Requests for Scheduled Alerts thread6 = new GnrtSchldAlertsfunc("ThreadSix"); thread6.setDaemon(true); thread6.setName("ThreadSix"); thread6.setPriority(Thread.MIN_PRIORITY); //System.out.println("Starting ThreadSix thread..."); thread6.start(); //Thread for Monitoring Scheduled Request Runs that are due but not running // and starting their appropriate process runners thread3 = new MntrSchdldRqtsNtRnngfunc("ThreadThree"); thread3.setDaemon(true); thread3.setName("ThreadThree"); thread3.setPriority(Thread.MIN_PRIORITY); //System.out.println("Starting ThreadThree thread..."); thread3.start(); //Thread for Monitoring User Request Runs that are due but not running // and starting their appropriate process runners thread4.setDaemon(true); thread4.setName("ThreadFour"); thread4.setPriority(Thread.MIN_PRIORITY); //System.out.println("Starting ThreadFour thread..."); thread4.start(); //Thread for Generating Run Requests for Scheduled Alerts thread7 = new MntrSchdldAlertsNtRnngfunc("ThreadSeven"); thread7.setDaemon(true); thread7.setName("ThreadSeven"); thread7.setPriority(Thread.MIN_PRIORITY); //System.out.println("Starting ThreadSeven thread..."); thread7.start(); //Thread for Running Requests for User Initiated Alerts thread8 = new MntrUserAlertsNtRnngfunc("ThreadEight"); thread8.setDaemon(true); thread8.setName("ThreadEight"); thread8.setPriority(Thread.MIN_PRIORITY); //System.out.println("Starting ThreadEight thread..."); thread8.start(); } } else { //Thread for running the actual Code behind the Request Run if this is the //Program supposed to run that request //i.e. if Global.runID >0 Global.minimizeMemory(); if (Global.runID > 0) { thread1 = new RqstLstnrUpdtrfunc("ThreadOne"); thread1.setDaemon(true); thread1.setName("ThreadOne"); thread1.setPriority(Thread.MIN_PRIORITY); //System.out.println("Starting ThreadOne thread..."); thread1.start(); thread5 = new RunActualRqtsfunc("ThreadFive"); thread5.setDaemon(true); thread5.setName("ThreadFive"); //System.out.println("Starting ThreadFive thread..."); if (rnnPryty.equals("1-Highest")) { thread1.setPriority(Thread.MAX_PRIORITY); } else if (rnnPryty.equals("2-AboveNormal")) { thread1.setPriority(7); } else if (rnnPryty.equals("3-Normal")) { thread1.setPriority(Thread.NORM_PRIORITY); } else if (rnnPryty.equals("4-BelowNormal")) { thread1.setPriority(3); } else { thread1.setPriority(1); } thread5.start(); } // Allow counting for 10 seconds. //Thread.Sleep(1000); } } } } catch (NumberFormatException ex) { Global.errorLog = ex.getMessage() + System.getProperty("line.separator") + Arrays.toString(ex.getStackTrace()); String fileLoc = Global.rnnrsBasDir + "/log_files/"; Date dNow = new Date(); SimpleDateFormat ft = new SimpleDateFormat("ddMMMyyyyHHmmss"); fileLoc += "Global.errorLog" + ft.format(dNow.getTime()) + ".rho"; PrintWriter fileWriter; try { fileWriter = new PrintWriter(fileLoc, "UTF-8"); fileWriter.println(Global.errorLog); fileWriter.close(); } catch (FileNotFoundException ex1) { Logger.getLogger(Program.class.getName()).log(Level.SEVERE, null, ex1); } catch (UnsupportedEncodingException ex1) { Logger.getLogger(Program.class.getName()).log(Level.SEVERE, null, ex1); } killThreads(); } catch (SQLException ex) { Global.errorLog = ex.getMessage() + System.getProperty("line.separator") + Arrays.toString(ex.getStackTrace()); String fileLoc = Global.rnnrsBasDir + "/log_files/"; Date dNow = new Date(); SimpleDateFormat ft = new SimpleDateFormat("ddMMMyyyyHHmmss"); fileLoc += "Global.errorLog" + ft.format(dNow.getTime()) + ".rho"; PrintWriter fileWriter; try { fileWriter = new PrintWriter(fileLoc, "UTF-8"); fileWriter.println(Global.errorLog); fileWriter.close(); } catch (FileNotFoundException ex1) { Logger.getLogger(Program.class.getName()).log(Level.SEVERE, null, ex1); } catch (UnsupportedEncodingException ex1) { Logger.getLogger(Program.class.getName()).log(Level.SEVERE, null, ex1); } killThreads(); } finally { } }
From source file:com.l2jfree.status.StatusServer.java
License:asdf
protected StatusServer() throws IOException { _socket = new ServerSocket( Integer.parseInt(new L2Properties(L2AutoInitialization.TELNET_FILE).getProperty("StatusPort"))); addFilter(new FloodFilter()); addFilter(new HostFilter()); setPriority(Thread.MAX_PRIORITY); setDaemon(true);/*w w w. j a v a2 s. c o m*/ start(); _log.info("Telnet: Listening on port: " + getServerSocket().getLocalPort()); }
From source file:io.mandrel.worker.WorkerContainer.java
public WorkerContainer(ExtractorService extractorService, Accumulators accumulators, Spider spider, Clients clients, DiscoveryClient discoveryClient) { super(accumulators, spider, clients); context.setDefinition(spider);//w w w. j ava2 s . c o m this.extractorService = extractorService; // Create the thread factory BasicThreadFactory threadFactory = new BasicThreadFactory.Builder() .namingPattern("worker-" + spider.getId() + "-%d").daemon(true).priority(Thread.MAX_PRIORITY) .build(); // Get number of parallel loops int parallel = Runtime.getRuntime().availableProcessors(); // Prepare a pool for the X parallel loops and the barrier refresh executor = Executors.newScheduledThreadPool(parallel + 1, threadFactory); // Prepare the barrier Barrier barrier = new Barrier(spider.getFrontier().getPoliteness(), discoveryClient); executor.scheduleAtFixedRate(() -> barrier.updateBuckets(), 10, 10, TimeUnit.SECONDS); // Create loop loops = new ArrayList<>(parallel); IntStream.range(0, parallel).forEach(idx -> { Loop loop = new Loop(extractorService, spider, clients, accumulators.spiderAccumulator(spider.getId()), accumulators.globalAccumulator(), barrier); loops.add(loop); executor.submit(loop); }); // Init stores MetadataStore metadatastore = spider.getStores().getMetadataStore().build(context); metadatastore.init(); MetadataStores.add(spider.getId(), metadatastore); BlobStore blobStore = spider.getStores().getBlobStore().build(context); blobStore.init(); BlobStores.add(spider.getId(), blobStore); if (spider.getExtractors().getData() != null) { spider.getExtractors().getData().forEach(ex -> { DocumentStore documentStore = ex.getDocumentStore().metadataExtractor(ex).build(context); documentStore.init(); DocumentStores.add(spider.getId(), ex.getName(), documentStore); }); } // Init requesters spider.getClient().getRequesters().forEach(r -> { Requester<?> requester = r.build(context); // Prepare client if (requester.strategy().nameResolver() != null) { requester.strategy().nameResolver().init(); } if (requester.strategy().proxyServersSource() != null) { requester.strategy().proxyServersSource().init(); } requester.init(); Requesters.add(spider.getId(), requester); }); current.set(ContainerStatus.INITIATED); }
From source file:com.crossbusiness.resiliency.aspect.AbstractTimeoutAspect.java
private ThreadFactory threadFactory() { CustomizableThreadFactory tf = new CustomizableThreadFactory("sumo-timeout-"); tf.setThreadPriority(Thread.MAX_PRIORITY); tf.setDaemon(true);//from w w w. j a va 2 s . c om tf.setThreadGroupName("resiliency"); return tf; }