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:es.udc.gii.common.eaf.algorithm.parallel.evaluation.DistributedEvaluation.java
protected void master(EvolutionaryAlgorithm algorithm, List<Individual> individuals, List<ObjectiveFunction> functions, List<Constraint> constraints) { /* Initialize the global state. */ this.functions = functions; this.constraints = constraints; this.popSize = individuals.size(); this.individualsToEvaluate = individuals; this.firtstInd = 0; this.evaluatedIndividuals = 0; if (this.barrier == null) { this.barrier = new CyclicBarrier(2); }//from w w w. j a v a 2s . c om boolean setChunkSizeToCero = false; if (getChunkSize() == 0) { setChunkSizeToCero = true; int size = individuals.size(); int tSize = getTopology().getSize(); if (size < tSize) { setChunkSize(1); } else { setChunkSize(size / tSize); } } notifyObservers(CURRENT_EVALUATION_STARTED, this); /* Initialize the communication thread. */ if (communicationThread == null) { communicationThread = new Thread(new CommunicationThread(), "CommThread"); communicationThread.setPriority(Thread.MAX_PRIORITY); Thread.currentThread().setPriority(Thread.MIN_PRIORITY); commThreadMustWait = true; communicationThread.start(); } else { synchronized (this.communicationThread) { commThreadMustWait = false; this.communicationThread.notify(); } } /* Run the evaluation thread (current thread, no especial thread is created) */ evaluationThread(algorithm); if (setChunkSizeToCero) { setChunkSize(0); } notifyObservers(CURRENT_EVALUATION_ENDED, this); setState(CURRENT_EVALUATION_NOT_STARTED); }
From source file:org.commoncrawl.service.listcrawler.CacheManager.java
private final void flushLocalLog(final long bytesToRemove, final int itemsToRemove, final List<FingerprintAndOffsetTuple> flushedTupleList, final ArrayList<IndexDataFileTriple> tempFileTriples) { LOG.info("Acquiring Log Access Semaphores"); // first boost this thread's priority ... int originalThreadPriority = Thread.currentThread().getPriority(); Thread.currentThread().setPriority(Thread.MAX_PRIORITY); // next acquire all permits to the local access log ... block until we get there ... getLocalLogAccessSemaphore().acquireUninterruptibly(LOG_ACCESS_SEMAPHORE_COUNT); // now that we have all the semaphores we need, reduce the thread's priority to normal Thread.currentThread().setPriority(originalThreadPriority); LOG.info("Acquired ALL Log Access Semaphores"); long timeStart = System.currentTimeMillis(); // now we have exclusive access to the local transaction log ... File activeLogFilePath = getActiveLogFilePath(); File checkpointLogFilePath = getCheckpointLogFilePath(); try {//from w w w .j a v a 2 s . com // delete checkpoint file if it existed ... checkpointLogFilePath.delete(); // now rename activelog to checkpoint path activeLogFilePath.renameTo(checkpointLogFilePath); long logFileConsolidationStartTime = System.currentTimeMillis(); // now trap for exceptions in case something fails try { // fix up the header ... _header._fileSize -= bytesToRemove; _header._itemCount -= itemsToRemove; // open a old file and new file RandomAccessFile newFile = new RandomAccessFile(activeLogFilePath, "rw"); RandomAccessFile oldFile = new RandomAccessFile(checkpointLogFilePath, "r"); LOG.info("Opened new and old files. New Header FileSize is:" + _header._fileSize + " ItemCount:" + _header._itemCount); try { // write out header ... long bytesRemainingInLogFile = _header._fileSize; LOG.info("Writing Header to New File. Bytes Remaining for Data are:" + bytesRemainingInLogFile); // write header to new file ... _header.writeHeader(newFile); // decrement bytes available ... bytesRemainingInLogFile -= LocalLogFileHeader.SIZE; if (bytesRemainingInLogFile != 0) { byte transferBuffer[] = new byte[(1 << 20) * 16]; LOG.info("Seeking old file past flushed data (pos:" + LocalLogFileHeader.SIZE + bytesToRemove + ")"); // seek past old data ... oldFile.seek(LocalLogFileHeader.SIZE + bytesToRemove); // and copy across remaining data while (bytesRemainingInLogFile != 0) { int bytesToReadWriteThisIteration = Math.min((int) bytesRemainingInLogFile, transferBuffer.length); oldFile.read(transferBuffer, 0, bytesToReadWriteThisIteration); newFile.write(transferBuffer, 0, bytesToReadWriteThisIteration); LOG.info("Copied " + bytesToReadWriteThisIteration + " from Old to New"); bytesRemainingInLogFile -= bytesToReadWriteThisIteration; } } } finally { if (newFile != null) { newFile.close(); } if (oldFile != null) { oldFile.close(); } } // if we reached here then checkpoint was successfull ... LOG.info("Checkpoint - Log Consolidation Successfull! TOOK:" + (System.currentTimeMillis() - logFileConsolidationStartTime)); LOG.info("Loading Index Files"); for (IndexDataFileTriple triple : tempFileTriples) { LOG.info("Loading Index File:" + triple._localIndexFilePath); final HDFSFileIndex fileIndex = new HDFSFileIndex(_remoteFileSystem, triple._localIndexFilePath, triple._dataFilePath); LOG.info("Loaded Index File"); // update hdfs index list ... synchronized (CacheManager.this) { LOG.info("Adding HDFS Index to list"); _hdfsIndexList.addElement(fileIndex); } } // create a semaphore to wait on final Semaphore semaphore = new Semaphore(0); LOG.info("Scheduling Async Event"); // now we need to schedule an async call to main thread to update data structures safely ... _eventLoop.setTimer(new Timer(0, false, new Timer.Callback() { @Override public void timerFired(Timer timer) { LOG.info("Cleaning Map"); synchronized (CacheManager.this) { // walk tuples for (FingerprintAndOffsetTuple tuple : flushedTupleList) { //TODO: HACK! // remove from collection ... _fingerprintToLocalLogPos.removeAll(tuple._fingerprint); } } LOG.info("Increment Offset Info"); // finally increment locallog offset by bytes removed ... _localLogStartOffset += bytesToRemove; LOG.info("Releasing Wait Semaphore"); //release wait sempahore semaphore.release(); } })); LOG.info("Waiting for Async Event to Complete"); //wait for async operation to complete ... semaphore.acquireUninterruptibly(); LOG.info("Async Event to Completed"); } catch (IOException e) { LOG.error("Checkpoint Failed with Exception:" + CCStringUtils.stringifyException(e)); // delete new file ... activeLogFilePath.delete(); // and rename checkpoint file to active file ... checkpointLogFilePath.renameTo(activeLogFilePath); } } finally { LOG.info("Releasing ALL Log Access Semaphores. HELD FOR:" + (System.currentTimeMillis() - timeStart)); getLocalLogAccessSemaphore().release(LOG_ACCESS_SEMAPHORE_COUNT); } }
From source file:org.opencms.search.CmsSearchIndex.java
/** * Adds a parameter.<p>/* w ww . ja va 2 s .co m*/ * * @param key the key/name of the parameter * @param value the value of the parameter */ public void addConfigurationParameter(String key, String value) { if (PERMISSIONS.equals(key)) { m_checkPermissions = Boolean.valueOf(value).booleanValue(); } else if (TIME_RANGE.equals(key)) { m_checkTimeRange = Boolean.valueOf(value).booleanValue(); } else if (EXCERPT.equals(key)) { m_createExcerpt = Boolean.valueOf(value).booleanValue(); } else if (EXTRACT_CONTENT.equals(key)) { m_extractContent = Boolean.valueOf(value).booleanValue(); } else if (BACKUP_REINDEXING.equals(key)) { m_backupReindexing = Boolean.valueOf(value).booleanValue(); } else if (MAX_HITS.equals(key)) { try { m_maxHits = Integer.parseInt(value); } catch (NumberFormatException e) { LOG.error(Messages.get().getBundle().key(Messages.LOG_INVALID_PARAM_3, value, key, getName())); } if (m_maxHits < (MAX_HITS_DEFAULT / 100)) { m_maxHits = MAX_HITS_DEFAULT; LOG.error(Messages.get().getBundle().key(Messages.LOG_INVALID_PARAM_3, value, key, getName())); } } else if (PRIORITY.equals(key)) { m_priority = Integer.parseInt(value); if (m_priority < Thread.MIN_PRIORITY) { m_priority = Thread.MIN_PRIORITY; LOG.error(Messages.get().getBundle().key(Messages.LOG_SEARCH_PRIORITY_TOO_LOW_2, value, new Integer(Thread.MIN_PRIORITY))); } else if (m_priority > Thread.MAX_PRIORITY) { m_priority = Thread.MAX_PRIORITY; LOG.debug(Messages.get().getBundle().key(Messages.LOG_SEARCH_PRIORITY_TOO_HIGH_2, value, new Integer(Thread.MAX_PRIORITY))); } } else if (LUCENE_MAX_MERGE_DOCS.equals(key)) { try { m_luceneMaxMergeDocs = Integer.valueOf(value); } catch (NumberFormatException e) { LOG.error(Messages.get().getBundle().key(Messages.LOG_INVALID_PARAM_3, value, key, getName())); } } else if (LUCENE_MERGE_FACTOR.equals(key)) { try { m_luceneMergeFactor = Integer.valueOf(value); } catch (NumberFormatException e) { LOG.error(Messages.get().getBundle().key(Messages.LOG_INVALID_PARAM_3, value, key, getName())); } } else if (LUCENE_RAM_BUFFER_SIZE_MB.equals(key)) { try { m_luceneRAMBufferSizeMB = Double.valueOf(value); } catch (NumberFormatException e) { LOG.error(Messages.get().getBundle().key(Messages.LOG_INVALID_PARAM_3, value, key, getName())); } } else if (LUCENE_USE_COMPOUND_FILE.equals(key)) { m_luceneUseCompoundFile = Boolean.valueOf(value); } }
From source file:pt.aptoide.backupapps.Aptoide.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (!isRunning) { Thread.currentThread().setPriority(Thread.MAX_PRIORITY); theme = new ContextThemeWrapper(this, R.style.DialogTheme); // currentAppsList = EnumAppsLists.Backup; // handlingMyapps = new ArrayList<ViewMyapp>(); queuedFlipperChanges = new ArrayList<EnumAptoideInterfaceTasks>(); // swypeDetector = new GestureDetector(new SwypeDetector()); // swypeListener = new View.OnTouchListener() { // @Override // public boolean onTouch(View v, MotionEvent event) { // return swypeDetector.onTouchEvent(event); // } // }; // swyping = new AtomicBoolean(false); // swypeDelayHandler = new Handler(); synchronizingInstalledApps = new AtomicBoolean(false); loadingRepos = new AtomicBoolean(false); // resettingFlipper = new AtomicBoolean(false); highPriority = new AtomicBoolean(true); makeSureServiceDataIsRunning();/*w w w. ja va 2 s.c o m*/ isRunning = true; setContentView(R.layout.aptoide); // searchView = (ImageView) findViewById(R.id.search_button); // searchView.setOnTouchListener(new SearchClickListener()); // previousViewArrow = (ImageView) findViewById(R.id.previous); // previousViewArrow.setOnClickListener(new OnPreviousClickedListener()); // previousViewArrow.setVisibility(View.INVISIBLE); // previousListTitle = (TextView) findViewById(R.id.previous_title); // previousListTitle.setText(getString(R.string.available)); // previousListTitle.setOnClickListener(new OnPreviousClickedListener()); // previousListTitle.setVisibility(View.INVISIBLE); // currentListTitle = (TextView) findViewById(R.id.current_title); // currentListTitle.setText(getString(R.string.available)); // currentListTitle.setClickable(false); // nextListTitle = (TextView) findViewById(R.id.next_title); // nextListTitle.setText(getString(R.string.installed)); // nextListTitle.setOnClickListener(new OnNextClickedListener()); // nextViewArrow = (ImageView) findViewById(R.id.next); // nextViewArrow.setOnClickListener(new OnNextClickedListener()); // View categoriesView = LinearLayout.inflate(this, R.layout.apps_list, appsListFlipper); View availableView = LinearLayout.inflate(this, R.layout.list_apps, appsListPager); View installedView = LinearLayout.inflate(this, R.layout.list_apps, appsListPager); // View updatableView = LinearLayout.inflate(this, R.layout.list_apps, appsListFlipper); // emptyCategoriesList = categoriesView.findViewById(android.R.id.empty); // emptyCategoriesList.setVisibility(View.GONE); // emptyAvailableAppsList = LinearLayout.inflate(this, R.layout.list_apps_empty, appsListFlipper); emptyAvailableAppsList = availableView.findViewById(android.R.id.empty); emptyAvailableAppsList.setVisibility(View.GONE); emptyAvailableAppsList.setTag(EnumAppsLists.RESTORE); // emptyInstalledAppsList = LinearLayout.inflate(this, R.layout.list_apps_empty, appsListFlipper); emptyInstalledAppsList = installedView.findViewById(android.R.id.empty); emptyInstalledAppsList.setVisibility(View.GONE); emptyInstalledAppsList.setTag(EnumAppsLists.BACKUP); // emptyUpdatableAppsList = LinearLayout.inflate(this, R.layout.list_apps_empty, appsListFlipper); // emptyUpdatableAppsList = updatableView.findViewById(android.R.id.empty); // emptyUpdatableAppsList.setVisibility(View.GONE); // emptyUpdatableAppsList.setTag(EnumAppsLists.Updates); // loadingCategoriesList = categoriesView.findViewById(R.id.loading); // loadingAvailableAppsList = LinearLayout.inflate(this, R.layout.list_loading, appsListFlipper); loadingAvailableAppsList = availableView.findViewById(R.id.loading); loadingAvailableAppsList.setTag(EnumAppsLists.RESTORE); loadingAppsTitle = loadingAvailableAppsList.findViewById(R.id.loading_title); loadingAppsTitleWaitingOnServer = loadingAvailableAppsList .findViewById(R.id.loading_title_waiting_on_server); loadingAvailableAppsUnknownProgress = (ProgressBar) loadingAvailableAppsList .findViewById(R.id.loading_bar); loadingAvailableAppsProgress = (ProgressBar) loadingAvailableAppsList .findViewById(R.id.loading_progress_bar); loadingAvailableAppsProgressCompletionTarget = new AtomicInteger(0); loadingAvailableAppsProgressCurrent = new AtomicInteger(0); // loadingInstalledAppsList = LinearLayout.inflate(this, R.layout.list_loading, appsListFlipper); loadingInstalledAppsList = installedView.findViewById(R.id.loading); loadingInstalledAppsList.setTag(EnumAppsLists.BACKUP); // loadingUpdatableAppsList = LinearLayout.inflate(this, R.layout.list_loading, appsListFlipper); // loadingUpdatableAppsList = updatableView.findViewById(R.id.loading); // loadingUpdatableAppsList.setTag(EnumAppsLists.Updates); // categoriesListView = new ListView(this); // categoriesListView = (ListView) categoriesView.findViewById(android.R.id.list); // categoriesListView.setCacheColorHint(Color.TRANSPARENT); // categoriesListView.setOnTouchListener(swypeListener); // categoriesListView.setOnItemClickListener(this); // categoriesListView.setTag(EnumAppsLists.Available); // categoriesListView.setPersistentDrawingCache(ViewGroup.PERSISTENT_ALL_CACHES); // availableAppsListView = new ListView(this); availableAppsListView = (ListView) availableView.findViewById(android.R.id.list); availableAppsListView.setCacheColorHint(Color.TRANSPARENT); // availableAppsListView.setOnTouchListener(swypeListener); availableAppsListView.setOnItemClickListener(this); availableAppsListView.setTag(EnumAppsLists.RESTORE); availableAppsListView.setPersistentDrawingCache(ViewGroup.PERSISTENT_ALL_CACHES); // appsListFlipper.addView(availableAppsList); // installedAppsListView = new ListView(this); installedAppsListView = (ListView) installedView.findViewById(android.R.id.list); installedAppsListView.setCacheColorHint(Color.TRANSPARENT); // installedAppsListView.setOnTouchListener(swypeListener); installedAppsListView.setOnItemClickListener(this); installedAppsListView.setTag(EnumAppsLists.BACKUP); installedAppsListView.setPersistentDrawingCache(ViewGroup.PERSISTENT_ALL_CACHES); // appsListFlipper.addView(installedAppsList); // updatableAppsListView = new ListView(this); // updatableAppsListView = (ListView) updatableView.findViewById(android.R.id.list); // updatableAppsListView.setCacheColorHint(Color.TRANSPARENT); // updatableAppsListView.setOnTouchListener(swypeListener); // updatableAppsListView.setOnItemClickListener(this); // updatableAppsListView.setTag(EnumAppsLists.Updates); // updatableAppsListView.setPersistentDrawingCache(ViewGroup.PERSISTENT_ALL_CACHES); // appsListFlipper.addView(updatableAppsList); Button backup = (Button) installedView.findViewById(R.id.action); backup.setText(R.string.backup_selected_apps); backup.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Log.d("Aptoide-AppsBackup", "Clicked on backup"); // if(selectedVersion.getRepoUri() != null){ // if(authenticationToken == null){ // try { // authenticationToken = serviceDataCaller.callGetServerToken(); // } catch (RemoteException e) { // // TODO Auto-generated catch block // e.printStackTrace(); // } // } // if(authenticationToken == null){ // Log.d("Aptoide-AppsBackup", "No login set"); // DialogLogin loginComments = new DialogLogin(AppInfo.this, serviceDataCaller, DialogLogin.InvoqueNature.NO_CREDENTIALS_SET); // loginComments.setOnDismissListener(new OnDismissListener() { // @Override // public void onDismiss(DialogInterface dialog) { // addAppVersionComment(); // } // }); // loginComments.show(); // }else{ // addAppVersionComment(); // } // } try { authenticationToken = serviceDataCaller.callGetServerToken(); } catch (RemoteException e) { e.printStackTrace(); } ViewListIds uploads = new ViewListIds(); for (int i = 0; i < installedAdapter.getCount(); i++) { if (((ViewDisplayApplicationBackup) installedAdapter.getItem(i)).isChecked()) { uploads.add(installedAdapter.getItem(i).getAppHashid()); } } if (uploads.size() > 0) { installedAdapter.unselectAll(); if (authenticationToken != null) { Intent upload = new Intent(Aptoide.this, Upload.class); upload.putIntegerArrayListExtra("uploads", uploads); startActivity(upload); } else { AptoideLog.d(Aptoide.this, "can't backup with no server login configured"); // Toast.makeText(Aptoide.this, R.string.login_required, Toast.LENGTH_SHORT).show(); login(uploads, EnumAppsLists.BACKUP); } } } }); Button restore = (Button) availableView.findViewById(R.id.action); restore.setText(R.string.restore_selected_apps); restore.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Log.d("Aptoide-AppsBackup", "Clicked on restore"); try { anyReposInUse = serviceDataCaller.callAnyReposInUse(); } catch (RemoteException e) { e.printStackTrace(); } ViewListIds restores = new ViewListIds(); ViewDisplayApplicationBackup app; for (int i = 0; i < availableAdapter.getCount(); i++) { app = ((ViewDisplayApplicationBackup) availableAdapter.getItem(i)); if (app.isChecked()) { restores.add(availableAdapter.getItem(i).getAppHashid()); Toast.makeText(Aptoide.this, getString(R.string.restoring_app, availableAdapter.getItem(i).getAppName()), Toast.LENGTH_SHORT).show(); } } availableAdapter.unselectAll(); if (anyReposInUse) { for (Integer appHashid : restores) { try { serviceDataCaller.callInstallApp(appHashid); } catch (RemoteException e) { e.printStackTrace(); } } } else { AptoideLog.d(Aptoide.this, "can't restore with no repo configured"); // Toast.makeText(Aptoide.this, R.string.login_required, Toast.LENGTH_SHORT).show(); login(restores, EnumAppsLists.RESTORE); } } }); ArrayList<View> pages = new ArrayList<View>(); pages.add(installedView); pages.add(availableView); appsListPager = (ViewPager) findViewById(R.id.list_pager); ViewPagerAdapter pagerAdapter = new ViewPagerAdapter(pages); appsListPager.setAdapter(pagerAdapter); pageIndicator = (FixedTabsView) findViewById(R.id.indicator); pageIndicatorAdapter = new FixedTabsAdapter(this); pageIndicator.setAdapter(pageIndicatorAdapter); pageIndicator.setViewPager(appsListPager); // appsListFlipper.addView(loadingAvailableAppsList); // appsListFlipper.addView(loadingInstalledAppsList); // appsListFlipper.addView(loadingUpdatableAppsList); // appsListPager.addView(availableView); // appsListPager.addView(installedView); // appsListFlipper.addView(updatableView); } }
From source file:com.nuvolect.deepdive.probe.DecompileApk.java
/** * Build a new DEX file excluding classes in the OPTIMIZED_CLASS_EXCLUSION file * @return// w w w.j ava2 s . c o m */ private JSONObject optimizeDex() { final Thread.UncaughtExceptionHandler uncaughtExceptionHandler = new Thread.UncaughtExceptionHandler() { @Override public void uncaughtException(Thread t, Throwable e) { LogUtil.log(LogUtil.LogType.DECOMPILE, "Uncaught exception: " + e.toString()); m_progressStream.putStream("Uncaught exception: " + t.getName()); m_progressStream.putStream("Uncaught exception: " + e.toString()); } }; m_optimize_dex_time = System.currentTimeMillis(); // Save start time for tracking m_optimizeDexThread = new Thread(m_threadGroup, new Runnable() { @Override public void run() { m_progressStream = new ProgressStream( new OmniFile(m_volumeId, m_appFolderPath + DEX_OPTIMIZATION_LOG_FILE)); m_progressStream .putStream("Optimizing classes, reference: " + OPTIMIZED_CLASSES_EXCLUSION_FILENAME); Scanner s = null; try { OmniFile omniFile = new OmniFile(m_volumeId, m_appFolderPath + OPTIMIZED_CLASSES_EXCLUSION_FILENAME); s = new Scanner(omniFile.getStdFile()); while (s.hasNext()) { String excludeClass = s.next(); ignoredLibs.add(excludeClass); m_progressStream.putStream("Exclude class: " + excludeClass); } } catch (Exception e) { LogUtil.logException(LogUtil.LogType.DECOMPILE, e); } if (s != null) s.close(); ArrayList<OmniFile> dexFiles = new ArrayList<>(); for (String fileName : m_dexFileNames) { OmniFile dexFile = new OmniFile(m_volumeId, m_appFolderPath + fileName + ".dex"); if (dexFile.exists() && dexFile.isFile()) { dexFiles.add(dexFile);// Keep track for summary List<ClassDef> classes = new ArrayList<>(); m_progressStream.putStream("Processing: " + fileName + ".dex"); org.jf.dexlib2.iface.DexFile memoryDexFile = null; try { memoryDexFile = DexFileFactory.loadDexFile(dexFile.getStdFile(), Opcodes.forApi(19)); } catch (Exception e) { m_progressStream.putStream("The app DEX file cannot be decompiled."); LogUtil.logException(LogUtil.LogType.DECOMPILE, e); continue; } int excludedClassCount = 0; Set<? extends ClassDef> origClassSet = memoryDexFile.getClasses(); memoryDexFile = null; // Release memory for (org.jf.dexlib2.iface.ClassDef classDef : origClassSet) { final String currentClass = classDef.getType(); if (isIgnored(currentClass)) { ++excludedClassCount; m_progressStream.putStream("Excluded class: " + currentClass); } else { m_progressStream.putStream("Included class: " + currentClass); classes.add(classDef); } } origClassSet = null; // Release memory m_progressStream.putStream("Excluded classes #" + excludedClassCount); m_progressStream.putStream("Included classes #" + classes.size()); m_progressStream.putStream("Rebuilding immutable dex: " + fileName + ".dex"); if (classes.size() > 0) { DexFile optDexFile = new ImmutableDexFile(Opcodes.forApi(19), classes); classes = null; // Release memory try { if (dexFile.delete()) m_progressStream.putStream("Fat DEX file delete success: " + dexFile.getName()); else m_progressStream.putStream("Fat DEX file delete FAILED: " + dexFile.getName()); DexPool.writeTo(dexFile.getStdFile().getAbsolutePath(), optDexFile); String size = NumberFormat.getNumberInstance(Locale.US).format(dexFile.length()); m_progressStream.putStream( "Optimized DEX file created: " + dexFile.getName() + ", size: " + size); } catch (IOException e) { m_progressStream.putStream("DEX IOException, write error: " + dexFile.getName()); LogUtil.logException(LogUtil.LogType.DECOMPILE, e); } catch (Exception e) { m_progressStream.putStream("DEX Exception, write error: " + dexFile.getName()); LogUtil.logException(LogUtil.LogType.DECOMPILE, e); } optDexFile = null; // release memory } else { m_progressStream .putStream("All classes excluded, DEX file not needed: " + dexFile.getName()); m_progressStream.putStream("Deleting: " + dexFile.getName()); dexFile.delete(); } } } for (OmniFile f : dexFiles) { if (f.exists()) { String formatted_count = String.format(Locale.US, "%,d", f.length()) + " bytes"; m_progressStream.putStream("DEX optimized: " + f.getName() + ": " + formatted_count); } else { m_progressStream.putStream("DEX deleted: " + f.getName() + ", all classes excluded"); } } dexFiles = new ArrayList<>();// Release memory m_progressStream .putStream("Optimize DEX complete: " + TimeUtil.deltaTimeHrMinSec(m_optimize_dex_time)); m_progressStream.close(); m_optimize_dex_time = 0; } }, UNZIP_APK_THREAD, STACK_SIZE); m_optimizeDexThread.setPriority(Thread.MAX_PRIORITY); m_optimizeDexThread.setUncaughtExceptionHandler(uncaughtExceptionHandler); m_optimizeDexThread.start(); return new JSONObject(); }
From source file:phex.download.swarming.SwarmingManager.java
/** * Forces a save of the download list. The call returns after the save is * completed. Only the shutdown routine is allowed to call this method! *///from ww w . j a va 2 s.c o m private void shutdownForceSaveDownloadList() { NLogger.debug(SwarmingManager.class, "Force save download list..."); synchronized (saveDownloadListLock) { if (saveDownloadListJob == null) { saveDownloadListJob = new SaveDownloadListJob(); saveDownloadListJob.start(); } else { saveDownloadListJob.triggerFollowUpSave(); } } try { if (saveDownloadListJob != null) { try { saveDownloadListJob.setPriority(Thread.MAX_PRIORITY); saveDownloadListJob.join(); } catch (NullPointerException exp) {// thread might be already finished and has set itself to null. } } } catch (InterruptedException exp) { NLogger.error(SwarmingManager.class, exp, exp); } }
From source file:edu.brown.hstore.HStoreSite.java
/** * Initializes all the pieces that we need to start this HStore site up * This should only be called by our run() method *///from w w w.jav a 2s . co m protected HStoreSite init() { if (debug.val) LOG.debug("Initializing HStoreSite " + this.getSiteName()); this.hstore_coordinator = this.initHStoreCoordinator(); // First we need to tell the HStoreCoordinator to start-up and initialize its connections if (debug.val) LOG.debug("Starting HStoreCoordinator for " + this.getSiteName()); this.hstore_coordinator.start(); ThreadGroup auxGroup = this.threadManager.getThreadGroup(ThreadGroupType.AUXILIARY); // Start TransactionQueueManager Thread t = new Thread(auxGroup, this.txnQueueManager); t.setDaemon(true); t.setUncaughtExceptionHandler(this.exceptionHandler); t.start(); // Start VoltNetwork t = new Thread(this.voltNetwork); t.setName(HStoreThreadManager.getThreadName(this, HStoreConstants.THREAD_NAME_VOLTNETWORK)); t.setDaemon(true); t.setUncaughtExceptionHandler(this.exceptionHandler); t.start(); // Start CommandLogWriter t = new Thread(auxGroup, this.commandLogger); t.setDaemon(true); t.setUncaughtExceptionHandler(this.exceptionHandler); t.start(); // Start AntiCacheManager Queue Processor if (this.anticacheManager != null && this.anticacheManager.getEvictableTables().isEmpty() == false) { t = new Thread(auxGroup, this.anticacheManager); t.setDaemon(true); t.setUncaughtExceptionHandler(this.exceptionHandler); t.start(); } // TransactionPreProcessors if (this.preProcessors != null) { for (TransactionPreProcessor tpp : this.preProcessors) { t = new Thread(this.threadManager.getThreadGroup(ThreadGroupType.PROCESSING), tpp); t.setDaemon(true); t.setUncaughtExceptionHandler(this.exceptionHandler); t.start(); } // FOR } // TransactionPostProcessors if (this.postProcessors != null) { for (TransactionPostProcessor tpp : this.postProcessors) { t = new Thread(this.threadManager.getThreadGroup(ThreadGroupType.PROCESSING), tpp); t.setDaemon(true); t.setUncaughtExceptionHandler(this.exceptionHandler); t.start(); } // FOR } // Then we need to start all of the PartitionExecutor in threads if (debug.val) LOG.debug(String.format("Starting PartitionExecutor threads for %s partitions on %s", this.local_partitions.size(), this.getSiteName())); for (int partition : this.local_partitions.values()) { PartitionExecutor executor = this.getPartitionExecutor(partition); // executor.initHStoreSite(this); t = new Thread(this.threadManager.getThreadGroup(ThreadGroupType.EXECUTION), executor); t.setDaemon(true); t.setPriority(Thread.MAX_PRIORITY); // Probably does nothing... t.setUncaughtExceptionHandler(this.exceptionHandler); this.executor_threads[partition] = t; t.start(); } // FOR // Start Transaction Cleaners int i = 0; for (TransactionCleaner cleaner : this.txnCleaners) { String name = String.format("%s-%02d", HStoreThreadManager.getThreadName(this, HStoreConstants.THREAD_NAME_TXNCLEANER), i); t = new Thread(this.threadManager.getThreadGroup(ThreadGroupType.CLEANER), cleaner); t.setName(name); t.setDaemon(true); t.setUncaughtExceptionHandler(this.exceptionHandler); t.start(); i += 1; } // FOR this.initPeriodicWorks(); // Transaction Profile CSV Dumper if (hstore_conf.site.txn_profiling && hstore_conf.site.txn_profiling_dump) { File csvFile = new File(hstore_conf.global.log_dir + File.separator + this.getSiteName().toLowerCase() + "-profiler.csv"); this.txn_profiler_dumper = new TransactionProfilerDumper(csvFile); LOG.info(String.format("Transaction profile data will be written to '%s'", csvFile)); } // Add in our shutdown hook // Runtime.getRuntime().addShutdownHook(new Thread(new ShutdownHook())); return (this); }
From source file:com.nuvolect.deepdive.probe.DecompileApk.java
private JSONObject dex2jar() { // DEX 2 JAR CONFIGS final boolean reuseReg = false; // reuse register while generate java .class file final boolean topologicalSort1 = false; // same with --topological-sort/-ts final boolean topologicalSort = false; // sort block by topological, that will generate more readable code final boolean verbose = true; // show progress final boolean debugInfo = false; // translate debug info final boolean printIR = false; // print ir to System.out final boolean optimizeSynchronized = true; // Optimise-synchronised final Thread.UncaughtExceptionHandler uncaughtExceptionHandler = new Thread.UncaughtExceptionHandler() { @Override/*from w ww. j a v a 2 s.co m*/ public void uncaughtException(Thread t, Throwable e) { LogUtil.log(LogUtil.LogType.DECOMPILE, "Uncaught exception: " + e.toString()); m_progressStream.putStream("Uncaught exception: " + t.getName()); m_progressStream.putStream("Uncaught exception: " + e.toString()); } }; m_dex2jar_time = System.currentTimeMillis(); // Save start time for tracking m_dex2jarThread = new Thread(m_threadGroup, new Runnable() { @Override public void run() { boolean success = false; OmniFile dexFile = null; OmniFile jarFile = null; m_progressStream.putStream("DEX to JAR starting"); for (String fileName : m_dexFileNames) { dexFile = new OmniFile(m_volumeId, m_appFolderPath + fileName + ".dex"); if (dexFile.exists() && dexFile.isFile()) { String size = NumberFormat.getNumberInstance(Locale.US).format(dexFile.length()); m_progressStream.putStream("DEX to JAR processing: " + dexFile.getName() + ", " + size); DexExceptionHandlerMod dexExceptionHandlerMod = new DexExceptionHandlerMod(); jarFile = new OmniFile(m_volumeId, m_appFolderPath + fileName + ".jar"); if (jarFile.exists()) jarFile.delete(); try { DexFileReader reader = new DexFileReader(dexFile.getStdFile()); Dex2jar dex2jar = Dex2jar.from(reader).reUseReg(reuseReg) .topoLogicalSort(topologicalSort || topologicalSort1).skipDebug(!debugInfo) .optimizeSynchronized(optimizeSynchronized).printIR(printIR); //.verbose(verbose); dex2jar.setExceptionHandler(dexExceptionHandlerMod); dex2jar.to(jarFile.getStdFile()); success = true; } catch (Exception e) { String ex = LogUtil.logException(LogUtil.LogType.DECOMPILE, e); m_progressStream.putStream(ex); m_progressStream.putStream("DEX to JAR failed: " + jarFile.getName()); success = false; continue; } if (success) { size = NumberFormat.getNumberInstance(Locale.US).format(jarFile.length()); m_progressStream.putStream("DEX to JAR succeeded: " + jarFile.getName() + ", " + size); } else { m_progressStream .putStream("Exception thrown, file cannot be decompiled: " + dexFile.getPath()); } } } if (jarFile == null) m_progressStream.putStream("No DEX file found: " + m_dexFileNames); m_progressStream.putStream("DEX to JAR complete: " + TimeUtil.deltaTimeHrMinSec(m_dex2jar_time)); m_dex2jar_time = 0; } }, DEX2JAR_THREAD, STACK_SIZE); m_dex2jarThread.setPriority(Thread.MAX_PRIORITY); m_dex2jarThread.setUncaughtExceptionHandler(uncaughtExceptionHandler); m_dex2jarThread.start(); JSONObject wrapper = new JSONObject(); try { wrapper.put("dex2jar_thread", getThreadStatus(true, m_dex2jarThread)); } catch (JSONException e) { LogUtil.logException(LogUtil.LogType.DECOMPILE, e); } return wrapper; }
From source file:hermes.browser.HermesBrowser.java
/** * Initialisation of GUI components, must be run on the Swing dispatch * thread./*w w w .j av a2s.c om*/ * * @throws ClassNotFoundException * @throws InstantiationException * @throws IllegalAccessException * @throws UnsupportedLookAndFeelException * @throws HermesException */ private void initUI() throws ClassNotFoundException, InstantiationException, IllegalAccessException, UnsupportedLookAndFeelException, HermesException { if (System.getProperty("swing.defaultlaf") == null) { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); /** * http://hermesjms.com/jira/browse/HJMS-16 I've not implemented * this fully as the L&F class name is not all we need to * persist, JIDE seems to add in lots of extension stuff and I * don't see how to persist/restor them yet. if * (TextUtils.isEmpty(getConfig().getLookAndFeel())) { * UIManager. * setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } * else { UIManager.setLookAndFeel(getConfig().getLookAndFeel()) * ; } */ } catch (Throwable e) { log.error("cannot load l&f, trying metal: " + e.getMessage(), e); UIManager.setLookAndFeel(new MetalLookAndFeel()); } } else { UIManager.setLookAndFeel(System.getProperty("swing.defaultlaf")); } if (getConfig().isEnableJython() && jythonFrame == null) { jythonFrame = new JythonDockableFrame(); getDockingManager().addFrame(jythonFrame); } if (!getConfig().isEnableJython() && jythonFrame != null) { getDockingManager().removeFrame(jythonFrame.getKey()); jythonFrame = null; } CellEditorManager.registerEditor(Domain.class, new DomainCellEditor()); CellEditorManager.registerEditor(SelectorImpl.class, new SelectorImplCellEditor()); CellEditorManager.registerEditor(File.class, new DirectoryCellEditor(), DirectoryCellEditor.CONTEXT); CellEditorManager.registerEditor(String.class, new ClasspathIdCellEdtitor(), ClasspathIdCellEdtitor.CONTEXT); CellEditorManager.registerEditor(Hermes.class, new HermesCellEditor()); ObjectComparatorManager.registerComparator(Date.class, new DateComparator()); ObjectComparatorManager.registerComparator(Integer.class, new IntegerComparator()); ObjectComparatorManager.registerComparator(Long.class, new LongComparator()); DefaultSyntaxKit.initKit(); browserPane = new MainDocumentPane(); // Shows us the memory usage and lets the user GC MemoryStatusBarItem memoryStatusBar = new MemoryStatusBarItem(); memoryStatusBar.setPreferredWidth(100); // General informative messages go here.. progressStatus = new ProgressStatusBarItem(); statusBar = new StatusBar(); statusBar.add(progressStatus, JideBoxLayout.VARY); statusBar.add(new TimeStatusBarItem(), JideBoxLayout.FLEXIBLE); statusBar.add(memoryStatusBar, JideBoxLayout.FLEXIBLE); // The tools panel includes the running tasks, Jython console and log // console. actionsPane = new ActionsPanel(); toolsPane = new DockableToolPanel(); toolsPane.addToolPanel("Tasks", new JideScrollPane(actionsPane)); toolsPane.addToolPanel("Log", new Log4JOutputViewer("")); browserTreePane = new BrowserTreeDockableFrame(); browserTreePane.setLoader(loader); // Get the menu bar initialised... setJMenuBar(new MenuBar(this)); setIconImage(IconCache.getIcon("hermes.icon").getImage()); // // Layout management initialisation getDockingManager().setUsePref(false); getDockingManager().setProfileKey(USER_PROFILE_NAME); getDockingManager().setInitSplitPriority(DefaultDockingManager.SPLIT_SOUTH_NORTH_EAST_WEST); getDockingManager().getWorkspace().add(browserPane, BorderLayout.CENTER); getDockingManager().addFrame(browserTreePane); getDockingManager().addFrame(toolsPane); getDockableBarManager().addDockableBar(new MainToolBar()); getDockableBarManager().addDockableBar(new MessageToolBar()); getDockableBarManager().addDockableBar(new ConfigurationToolBar()); getDockableBarManager().addDockableBar(new JNDIToolBar()); getContentPane().add(statusBar, BorderLayout.AFTER_LAST_LINE); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); toFront(); setStatusMessage("Ready"); SplashScreen.hide(); // // Raise the swing thread to max priority SwingUtilities.invokeLater(new Runnable() { public void run() { Thread.currentThread().setPriority(Thread.MAX_PRIORITY); } }); }
From source file:com.stimulus.archiva.presentation.ConfigBean.java
public String configure() throws ArchivaException { Thread.currentThread().setPriority(Thread.MAX_PRIORITY); SubmitButton button = getSubmitButton(); if (button == null | button.action == null) return "reload"; logger.debug("configure() {action ='" + button.action + "', value='" + button.value + "'}"); if (button.action.equals("newvolume")) { return newVolume(); } else if (button.action.equals("deletevolume")) { return deleteVolume(Integer.parseInt(button.value)); } else if (button.action.equals("prioritizevolume")) { return prioritizeVolume(Integer.parseInt(button.value)); } else if (button.action.equals("deprioritizevolume")) { return dePrioritizeVolume(Integer.parseInt(button.value)); } else if (button.action.equals("newarchiverule")) { return newArchiveRule(); } else if (button.action.equals("deletearchiverule")) { return deleteArchiveRule(Integer.parseInt(button.value)); } else if (button.action.equals("prioritizearchiverule")) { return prioritizeArchiveRule(Integer.parseInt(button.value)); } else if (button.action.equals("deprioritizearchiverule")) { return dePrioritizeArchiveRule(Integer.parseInt(button.value)); } else if (button.action.equals("cancel")) { return cancel(); } else if (button.action.equals("indexvolume")) { return indexVolume(Integer.parseInt(button.value)); } else if (button.action.equals("newadrolemap")) { return newAdRoleMap(); } else if (button.action.equals("deleteadrolemap")) { return deleteAdRoleMap(Integer.parseInt(button.value)); } else if (button.action.equals("newbasicrolemap")) { return newBasicRoleMap(); } else if (button.action.equals("deletebasicrolemap")) { return deleteBasicRoleMap(Integer.parseInt(button.value)); } else if (button.action.equals("newdomain")) { return newDomain(); } else if (button.action.equals("deletedomain")) { return deleteDomain(Integer.parseInt(button.value)); } else if (button.action.equals("closevolume")) { return closeVolume(Integer.parseInt(button.value)); } else if (button.action.equals("unmountvolume")) { return unmountVolume(Integer.parseInt(button.value)); } else if (button.action.equals("newagentipaddress")) { return newAgentIPAddress(); } else if (button.action.equals("deleteagentipaddress")) { return deleteAgentIPAddress(Integer.parseInt(button.value)); } else if (button.action.equals("reload")) { return reload(); } else if (button.action.equals("recoveremails")) { return recoverEmails(); } else if (button.action.equals("quarantineemails")) { return quarantine(); } else if (button.action.equals("testmailboxconnection")) { return testMailboxConnection(); } else if (button.action.equals("newarchiveruleclause")) { return newArchiveRuleClause(Integer.parseInt(button.value)); } else if (button.action.equals("deletearchiveruleclause")) { int dotpos = button.value.indexOf('.'); String id = button.value.substring(0, dotpos); String cid = button.value.substring(dotpos + 1, button.value.length()); return deleteArchiveRuleClause(Integer.parseInt(id), Integer.parseInt(cid)); } else if (button.action.equals("downloadlog")) { setLogFile(button.value);/*from w w w. ja v a2 s . co m*/ return "downloadlog"; } else if (button.action.equals("deletelog")) { return deleteLog(button.value); } ActionContext ctx = ActionContext.getActionContext(); if (ctx.isSimpleErrorsExist()) return reload(); if (!createVolumeDirectories()) return reload(); boolean error = false; if (!error) { setSimpleMessage(getMessage("config.saved")); } MailArchivaPrincipal principal = getMailArchivaPrincipal(); config.saveSettings(principal, true); config.loadSettings(principal); Config.getConfig().loadSettings(principal); Config.getConfig().getServices().reloadConfigAll(); MessageService.init(); // initialize cipher keys (for new password) ConfigurationService.setLoggingLevel(logLevel); return save(); }