List of usage examples for java.util.logging Level FINER
Level FINER
To view the source code for java.util.logging Level FINER.
Click Source Link
From source file:org.b3log.latke.repository.gae.GAERepository.java
/** * Caches the specified query results with the specified query. * //from w w w.ja va2 s .c o m * @param results the specified query results * @param query the specified query * @throws JSONException json exception */ private void cacheQueryResults(final JSONArray results, final org.b3log.latke.repository.Query query) throws JSONException { String cacheKey; for (int i = 0; i < results.length(); i++) { final JSONObject jsonObject = results.optJSONObject(i); // 1. Caching for get by id. cacheKey = CACHE_KEY_PREFIX + jsonObject.optString(Keys.OBJECT_ID); CACHE.putAsync(cacheKey, jsonObject); LOGGER.log(Level.FINER, "Added an object[cacheKey={0}] in repository cache[{1}] for default index[oId]", new Object[] { cacheKey, getName() }); // 2. Caching for get by query with filters (EQUAL operator) only final Set<String[]> indexes = query.getIndexes(); final StringBuilder logMsgBuilder = new StringBuilder(); for (final String[] index : indexes) { final org.b3log.latke.repository.Query futureQuery = new org.b3log.latke.repository.Query() .setPageCount(1); for (int j = 0; j < index.length; j++) { final String propertyName = index[j]; futureQuery.setFilter( new PropertyFilter(propertyName, FilterOperator.EQUAL, jsonObject.opt(propertyName))); logMsgBuilder.append(propertyName).append(","); } logMsgBuilder.deleteCharAt(logMsgBuilder.length() - 1); // Removes the last comma cacheKey = CACHE_KEY_PREFIX + futureQuery.getCacheKey() + "_" + getName(); final JSONObject futureQueryRet = new JSONObject(); final JSONObject pagination = new JSONObject(); futureQueryRet.put(Pagination.PAGINATION, pagination); pagination.put(Pagination.PAGINATION_PAGE_COUNT, 1); final JSONArray futureQueryResults = new JSONArray(); futureQueryRet.put(Keys.RESULTS, futureQueryResults); futureQueryResults.put(jsonObject); CACHE.putAsync(cacheKey, futureQueryRet); LOGGER.log(Level.FINER, "Added an object[cacheKey={0}] in repository cache[{1}] for index[{2}] for future query[{3}]", new Object[] { cacheKey, getName(), logMsgBuilder, futureQuery.toString() }); } } }
From source file:com.ibm.datapower.amt.clientAPI.Blob.java
/** * Get the contents of the blob as a byte array. * <p>//w ww . j a v a2 s .c o m * If the Blob was initially constructed via a byte array, it will just * return a reference to that same byte array. * <p> * If the Blob was initially constructed via a File, it will open the file, * allocate a byte array large enough to hold the contents, read the file * into that byte array, and return a reference to the byte array. Doing * that may be quite expensive if the file is large. This method does not * cause this object to have a reference to the byte array, so as soon as * the caller is done with the return value it may be eligible for garbage * collection. * <p> * This method needs to be public so it can be invoked by the dataAPI. * * @return a byte array representation of the binary data * @throws IOException * there was a problem reading the file while converting it to a * byte array. */ public byte[] getByteArray() throws IOException { final String METHOD_NAME = "getByteArray"; //$NON-NLS-1$ byte[] result = null; if (this.bytes != null) { result = this.bytes; } else if ((this.file != null) || (this.url != null)) { // need to load it if (this.file != null) { logger.logp(Level.FINER, CLASS_NAME, METHOD_NAME, "Creating byte array in Blob from file: " + this.file.getAbsolutePath()); //$NON-NLS-1$ } else { logger.logp(Level.FINER, CLASS_NAME, METHOD_NAME, "Creating byte array in Blob from url" + this.url.toString()); //$NON-NLS-1$ } InputStream inputStream = this.getInputStream(); // read in 4k chunks until we determine the size int totalBytes = 0; int bytesRead = 0; byte[] buffer = new byte[4096]; while ((bytesRead = inputStream.read(buffer, 0, 4096)) > 0) { totalBytes += bytesRead; } inputStream.close(); inputStream = this.getInputStream(); // Read the blob into a byte array now that we know the size result = new byte[totalBytes]; int increment = 4096; if (totalBytes < increment) { increment = totalBytes; } int bufferIndex = 0; while ((bytesRead = inputStream.read(result, bufferIndex, increment)) > 0) { bufferIndex += bytesRead; if ((totalBytes - bufferIndex) < 4096) { increment = totalBytes - bufferIndex; } } inputStream.close(); } else { // this should not happen logger.logp(Level.INFO, CLASS_NAME, METHOD_NAME, Messages.getString("wamt.clientAPI.Blob.internalErr", this.toString())); //$NON-NLS-1$ } if (result != null) logger.logp(Level.FINEST, CLASS_NAME, METHOD_NAME, "Returning byte array, length: " + result.length); //$NON-NLS-1$ String message = "First 20 bytes of Blob: "; //$NON-NLS-1$ StringBuffer buf = new StringBuffer(message); for (int i = 0; i < 20 && i < result.length; i++) { int a = result[i]; buf.append(Integer.toHexString(a & 0xff) + " "); //$NON-NLS-1$ } message = buf.toString(); logger.logp(Level.FINEST, CLASS_NAME, METHOD_NAME, message); return (result); }
From source file:org.apache.oodt.cas.filemgr.datatransfer.LocalDataTransferer.java
private void moveDirToProductRepo(Product product) throws IOException, URISyntaxException { Reference dirRef = product.getProductReferences().get(0); LOG.log(Level.INFO, "LocalDataTransferer: Moving Directory: " + dirRef.getOrigReference() + " to " + dirRef.getDataStoreReference()); // notify the file manager that we started quietNotifyTransferProduct(product); for (Reference r : product.getProductReferences()) { File fileRef = new File(new URI(r.getOrigReference())); if (fileRef.isFile()) { moveFile(r, false);/*from w w w . j ava2 s .co m*/ } else if (fileRef.isDirectory() && (fileRef.list() != null && fileRef.list().length == 0)) { // if it's a directory and it doesn't exist yet, we should // create it // just in case there's no files in it if (!new File(new URI(r.getDataStoreReference())).exists()) { LOG.log(Level.FINER, "Directory: [" + r.getDataStoreReference() + "] doesn't exist: creating it"); try { FileUtils.forceMkdir(new File(new URI(r.getDataStoreReference()))); } catch (IOException e) { LOG.log(Level.WARNING, "Unable to create directory: [" + r.getDataStoreReference() + "] in local data transferer"); } } } } // notify the file manager that we're done quietNotifyProductTransferComplete(product); }
From source file:com.ibm.team.build.internal.hjplugin.RTCFacadeFactory.java
private static URL[] getToolkitJarURLs(File toolkitFile, PrintStream debugLog) throws IOException { File[] files = toolkitFile.listFiles(new FileFilter() { public boolean accept(File file) { return file.getName().toLowerCase().endsWith(".jar") && !file.isDirectory(); //$NON-NLS-1$ }// w w w.ja v a 2s .com }); if (files == null) { throw new RuntimeException(Messages.RTCFacadeFactory_scan_error(toolkitFile.getAbsolutePath())); } // Log what we found if (LOGGER.isLoggable(Level.FINER) || debugLog != null) { String eol = System.getProperty("line.separator"); //$NON-NLS-1$ StringBuilder message = new StringBuilder("Found ").append(files.length) //$NON-NLS-1$ .append(" jars in ").append(toolkitFile.getAbsolutePath()).append(eol); //$NON-NLS-1$ for (File file : files) { message.append(file.getName()).append(eol); } debug(debugLog, message.toString()); } URL[] urls = new URL[files.length]; for (int i = 0; i < files.length; ++i) { urls[i] = files[i].toURI().toURL(); } return urls; }
From source file:edu.umass.cs.gigapaxos.PaxosInstanceStateMachine.java
PaxosInstanceStateMachine(String groupId, int version, int id, Set<Integer> gms, Replicable app, String initialState, PaxosManager<?> pm, final HotRestoreInfo hri, boolean missedBirthing) { /* Final assignments: A paxos instance is born with a paxosID, version * this instance's node ID, the application request handler, the paxos * manager, and the group members. */ this.paxosID = PAXOS_ID_AS_STRING ? groupId : groupId.getBytes(); this.version = version; // this.clientRequestHandler = app; this.paxosManager = pm; assert (gms != null && gms.size() > 0); Arrays.sort(this.groupMembers = Util.setToIntArray(gms)); /**************** End of final assignments *******************/ /* All non-final state is store in PaxosInstanceState (for acceptors) or * in PaxosCoordinatorState (for coordinators) that inherits from * PaxosInstanceState. *///w w w.j a v a2 s . com if (pm != null && hri == null) initiateRecovery(initialState, missedBirthing); else if ((hri != null) && hotRestore(hri)) { if (initialState != null) // batched creation // this.putInitialState(initialState); this.restore(initialState); } else if (pm == null) testingNoRecovery(); // used only for testing size assert (hri == null || initialState == null || hri.isCreateHRI()) : "Can not specify initial state for existing, paused paxos instance"; incrInstanceCount(); // for instrumentation // log creation only if the number of instances is small log.log(((hri == null || initialState != null) && notManyInstances()) ? Level.INFO : Level.FINER, "Node{0} initialized paxos {1} {2} with members {3}; {4} {5} {6}", new Object[] { this.getNodeID(), (this.paxosState.getBallotCoordLog() == this.getMyID() ? "coordinator" : "acceptor"), this.getPaxosIDVersion(), Util.arrayOfIntToString(groupMembers), this.paxosState, this.coordinator, (initialState == null ? "{recovered_state=[" + Util.prefix(this.getCheckpointState(), 64) : "{initial_state=[" + initialState) + "]}" }); }
From source file:com.ibm.jaggr.core.impl.transport.AbstractHttpTransport.java
protected void setRequestedModuleNames(HttpServletRequest request) throws IOException { final String sourceMethod = "setRequestedModuleNames"; //$NON-NLS-1$ boolean isTraceLogging = log.isLoggable(Level.FINER); if (isTraceLogging) { log.entering(AbstractHttpTransport.class.getName(), sourceMethod, new Object[] { request.getQueryString() }); }/*from w w w. j a v a2 s . co m*/ RequestedModuleNames requestedModuleNames = null; if (moduleIdList == null) { requestedModuleNames = new RequestedModuleNames(request, null, null); } else { requestedModuleNames = new RequestedModuleNames(request, moduleIdList, Arrays.copyOf(moduleIdListHash, moduleIdListHash.length)); } request.setAttribute(REQUESTEDMODULENAMES_REQATTRNAME, requestedModuleNames); if (isTraceLogging) { log.exiting(AbstractHttpTransport.class.getName(), sourceMethod); } }
From source file:ComputeNode.java
/** * Internal method to get load/*from w w w . j a va 2 s . co m*/ */ private Double getCurrentLoad() { // can be a simulated load or command output // can use taskCount Double currLoad = 0d; try { Process p = Runtime.getRuntime().exec("uptime"); BufferedReader stdInput = new BufferedReader(new InputStreamReader(p.getInputStream())); BufferedReader stdError = new BufferedReader(new InputStreamReader(p.getErrorStream())); // read the output from the command // 11:57:57 up 29 min, 2 users, load average: 0.27, 0.12, 0.09 String s; //System.out.println("Here is the standard output of the command:\n"); s = stdInput.readLine(); s = s.replace(':', ','); String data[] = s.split(","); currLoad = Double.parseDouble(data[data.length - 2]); } catch (Exception e) { lg.log(Level.WARNING, "getCurrentLoad: Unable to parse system " + " load information! Using constant,guassian or 0 "); } if (loadConstant != null) { currLoad = loadConstant; } else { if (loadGaussian != null) { currLoad = RandomGaussian.getGaussian(loadGaussian.fst(), loadGaussian.snd()); } else { currLoad = 0.0; } } myNodeStats.setCurrentLoad(currLoad); myNodeStats.noOfLoadChecks.incrementAndGet(); myNodeStats.setTotalLoad(myNodeStats.getTotalLoad() + currLoad); lg.log(Level.FINER, " getCurrentLoad: Load " + currLoad); return currLoad; }
From source file:ComputeNode.java
@Override public Boolean taskTransferRequest(Task task) throws RemoteException { Double load = getCurrentLoad(); myNodeStats.getNoOfTransferRequests().incrementAndGet(); lg.log(Level.FINER, "currLoad :" + load + " expectedLoad: " + task.getExpectedLoad() + " overLoadThreshold :" + overLoadThreshold); if (load + task.getExpectedLoad() > overLoadThreshold) { return false; }//from w w w. j a va 2 s .c om try { InetAddress ownIP = InetAddress.getLocalHost(); String localIP = ownIP.getHostAddress(); task.setNode(new Pair(id, localIP)); } catch (UnknownHostException e) { // TODO Auto-generated catch block e.printStackTrace(); } server.updateTaskTransfer(task); Thread t = new TaskExecutor(task); t.start(); // spawn task request... return true; }
From source file:org.b3log.latke.plugin.PluginManager.java
/** * Registers event listeners with the specified plugin properties, class * loader and plugin.//w w w . j a v a2 s . c o m * * <p> * <b>Note</b>: If the specified plugin has some event listeners, each * of these listener MUST implement a static method named * {@code getInstance} to obtain an instance of this listener. See * <a href="http://en.wikipedia.org/wiki/Singleton_pattern"> * Singleton Pattern</a> for more details. * </p> * * @param props the specified plugin properties * @param classLoader the specified class loader * @param plugin the specified plugin * @throws Exception exception */ private static void registerEventListeners(final Properties props, final URLClassLoader classLoader, final AbstractPlugin plugin) throws Exception { final String eventListenerClasses = props.getProperty(Plugin.PLUGIN_EVENT_LISTENER_CLASSES); final String[] eventListenerClassArray = eventListenerClasses.split(","); for (int i = 0; i < eventListenerClassArray.length; i++) { final String eventListenerClassName = eventListenerClassArray[i]; if (Strings.isEmptyOrNull(eventListenerClassName)) { LOGGER.log(Level.INFO, "No event listener to load for plugin[name={0}]", plugin.getName()); return; } LOGGER.log(Level.FINER, "Loading event listener[className={0}]", eventListenerClassName); final Class<?> eventListenerClass = classLoader.loadClass(eventListenerClassName); final Method getInstance = eventListenerClass.getMethod("getInstance"); final AbstractEventListener<?> eventListener = (AbstractEventListener) getInstance .invoke(eventListenerClass); final EventManager eventManager = EventManager.getInstance(); eventManager.registerListener(eventListener); LOGGER.log(Level.FINER, "Registered event listener[class={0}, eventType={1}] for plugin[name={2}]", new Object[] { eventListener.getClass(), eventListener.getEventType(), plugin.getName() }); } }
From source file:com.ibm.team.build.internal.hjplugin.RTCFacadeFactory.java
private static void debug(PrintStream debugLog, String msg, Exception e) { LOGGER.log(Level.FINER, msg, e); if (debugLog != null) { debugLog.println(msg);/*from ww w . j a v a 2 s .c om*/ e.printStackTrace(debugLog); } }