public void invoke( Pointer streamRef, Pointer clientCallBackInfo, NativeLong numEvents, Pointer eventPaths, Pointer eventFlags, Pointer eventIds) { final long st = System.currentTimeMillis(); final int length = numEvents.intValue(); final Pointer[] pointers = eventPaths.getPointerArray(0, length); final int[] flags = eventFlags.getIntArray(0, length); for (int i = 0; i < length; i++) { final Pointer p = pointers[i]; final int flag = flags[i]; boolean found = false; final String path = p.getString(0); final Key key = listensOn.get(path); if (key != null) { if ((flag & kFSEventStreamEventFlagMustScanSubDirs) == kFSEventStreamEventFlagMustScanSubDirs || (flag & kFSEventStreamEventFlagMount) == kFSEventStreamEventFlagMount || (flag & kFSEventStreamEventFlagUnmount) == kFSEventStreamEventFlagUnmount) { events.add(createEvent(key, EventKind.OVERFLOW, path)); } else { events.add(createEvent(key, EventKind.MODIFY, path)); } found = true; } LOG.log(DEBUG_LOG_LEVEL, "Event on {0} interesting: {1}", new Object[] {path, found}); } LOG.log(PERF_LOG_LEVEL, "Callback time: {0}", (System.currentTimeMillis() - st)); }
@Override public ByteBuffer readPage(File file, long position, ByteBuffer pageBuffer) throws IOException, InterruptedException { long start = System.currentTimeMillis(); RandomAccessFile randomAccessFile = randomAccessFile(file); try { randomAccessFile.seek(position); randomAccessFile.readFully(pageBuffer.array(), pageBuffer.arrayOffset(), pageSizeBytes); if (Thread.interrupted()) { throw new InterruptedException(); } long stop = System.currentTimeMillis(); if (LOG.isLoggable(Level.FINE)) { LOG.log( Level.FINE, "Read page at {0} of {1}: {2} msec", new Object[] {position, file, stop - start}); } } catch (EOFException e) { LOG.log( Level.SEVERE, "Caught EOFException while reading {0}, position {1}", new Object[] {file, position}); LOG.log(Level.SEVERE, "stack", e); throw e; } finally { randomAccessFile.close(); } return pageBuffer; }
public List<User> getAll() { try { connection = connectionFactory.getConnection(); String sql = "SELECT * FROM eeproject.Login;"; Statement statement = connection.createStatement(); ResultSet rs = statement.executeQuery(sql); while (rs.next()) { User user = new User(); user.setUsername(rs.getString(1)); user.setPassword(rs.getString(2)); LOG.log(Level.INFO, "User: "******"List size: " + list.size()); } } catch (SQLException ex) { LOG.log(Level.SEVERE, null, ex); } finally { connectionFactory.closeConnection(); LOG.log(Level.INFO, "Connection closed"); } return list; }
@Override public void resultChanged(LookupEvent ev) { TopComponent tc = ref.get(); if (tc == null) { r.removeLookupListener(this); synchronized (lookupListeners) { lookupListeners.remove(this); } return; } if (LOG.isLoggable(Level.FINER)) { LOG.log(Level.FINER, " looking result changed for {0} ", new Object[] {ref.get()}); } DataObject tcDataObject = tc.getLookup().lookup(DataObject.class); if (tcDataObject != null) { try { if (hasOpenedEditorPanes(tcDataObject)) { addOpenedFiles(getFiles(tcDataObject)); } } catch (InterruptedException ex) { LOG.log(Level.WARNING, null, ex); } catch (InvocationTargetException ex) { LOG.log(Level.WARNING, null, ex); } r.removeLookupListener(this); synchronized (lookupListeners) { lookupListeners.remove(this); } } }
public final void run() { byte[] buf = new byte[PayloadUtil.MTU]; try { while (!stopped) { DatagramPacket packet = new DatagramPacket(buf, buf.length); try { socket.receive(packet); byte[] payload = packet.getData(); processPayload(payload); } catch (IOException e) { if (!stopped) { LOG.log( Level.SEVERE, "Error receiving heartbeat. " + e.getMessage() + ". Initial cause was " + e.getMessage(), e); } } } } catch (Throwable t) { LOG.log( Level.SEVERE, "Multicast receiver thread caught throwable. Cause was " + t.getMessage() + ". Continuing..."); } }
private ErdoTransactionTest(String[] args) throws IOException, InterruptedException { // Database setup FileUtil.deleteDirectory(DB_DIRECTORY); db = Database.createDatabase(DB_DIRECTORY, configuration()); accounts = db.createMap(MAP_NAME, AccountId.class, Account.class); int a = 0; this.nAccounts = Integer.parseInt(args[a++]); this.threads = new ErdoTestThread[Integer.parseInt(args[a++])]; this.transactionsPerThread = Integer.parseInt(args[a++]); LOG.log(Level.INFO, "accounts: {0}", nAccounts); LOG.log(Level.INFO, "threads: {0}", threads.length); LOG.log(Level.INFO, "transactions per thread: {0}", transactionsPerThread); }
private void verify() throws IOException, InterruptedException { long sum = 0; Cursor cursor = accounts.first(); Account account; while ((account = (Account) cursor.next()) != null) { LOG.log(Level.INFO, "{0}", account); sum += account.balance(); } db.commitTransaction(); if (sum == 0) { LOG.log(Level.INFO, "OK!"); } else { LOG.log(Level.WARNING, "Test failed, sum = {0}", sum); } }
@Nullable @Override public InputStream openStream() { if (uri == null) return null; try { return new BufferedInputStream(new URI(uri).toURL().openStream()); } catch (FileNotFoundException e) { LOG.log(Level.SEVERE, "File not found", e); } catch (IOException e) { LOG.log(Level.SEVERE, "Other IO error", e); } catch (URISyntaxException e) { LOG.log(Level.SEVERE, "Bad URI", e); } return null; }
private void deliver() { try { executor.execute(this); } catch (Throwable t) { LOG.log(Level.INFO, "Exception notifying context listener", t); } }
protected final synchronized void schedule() { if (null == manager.getTimer()) { return; } class ResendTask extends TimerTask { ResendCandidate candidate; ResendTask(ResendCandidate c) { candidate = c; } @Override public void run() { if (!candidate.isPending()) { candidate.initiate(includeAckRequested); } } } nextTask = new ResendTask(this); try { manager.getTimer().schedule(nextTask, next); } catch (IllegalStateException ex) { LOG.log(Level.WARNING, "SCHEDULE_RESEND_FAILED_MSG", ex); } }
/** @param ctx message context for the unacked message */ protected ResendCandidate(Message m) { message = m; retries = 0; RMConfiguration cfg = manager.getEffectiveConfiguration(message); long baseRetransmissionInterval = cfg.getBaseRetransmissionInterval().longValue(); backoff = cfg.isExponentialBackoff() ? RetransmissionQueue.DEFAULT_EXPONENTIAL_BACKOFF : 1; next = new Date(System.currentTimeMillis() + baseRetransmissionInterval); nextInterval = baseRetransmissionInterval * backoff; RetryPolicyType rmrp = null != manager.getSourcePolicy() ? manager.getSourcePolicy().getRetryPolicy() : null; maxRetries = null != rmrp ? rmrp.getMaxRetries() : -1; AddressingProperties maps = RMContextUtils.retrieveMAPs(message, false, true); AttributedURIType to = null; if (null != maps) { to = maps.getTo(); } if (to != null && RMUtils.getAddressingConstants().getAnonymousURI().equals(to.getValue())) { LOG.log(Level.INFO, "Cannot resend to anonymous target. Not scheduling a resend."); return; } RMProperties rmprops = RMContextUtils.retrieveRMProperties(message, true); if (null != rmprops) { number = rmprops.getSequence().getMessageNumber(); } if (null != manager.getTimer() && maxRetries != 0) { schedule(); } }
@Override public void onClose(CachedOutputStream cos) { long l = LOG.logStart(); byte[] buf = new byte[1024]; int len; InputStream is; try { is = cos.getInputStream(); while ((len = is.read(buf)) > 0) { logOutputStream.write(buf, 0, len); } } catch (IOException ex) { LOG.logError(l, ex); } LoggingMessage buffer = setupBuffer(message, fout); LOG.log(buffer.toString()); try { // empty out the cache cos.lockOutputStream(); cos.resetOut(null, false); } catch (Exception ex) { LOG.logWarn(l, "Error clearing cache: " + ex.getMessage(), null); } message.setContent(OutputStream.class, origStream); }
private void change(FileEvent fe) { synchronized (saveActions) { for (AtomicAction a : saveActions) { if (fe.firedFrom(a)) { return; } } } String path; FileObject f = fe.getFile(); synchronized (modifiedMetadataPaths) { if (f.equals(resolveFileObject(PROJECT_XML_PATH))) { if (modifiedMetadataPaths.contains(PROJECT_XML_PATH)) { // #68872: don't do anything if the given file has non-saved changes: return; } path = PROJECT_XML_PATH; projectXmlValid = false; } else if (f.equals(resolveFileObject(PRIVATE_XML_PATH))) { if (modifiedMetadataPaths.contains(PRIVATE_XML_PATH)) { // #68872: don't do anything if the given file has non-saved changes: return; } path = PRIVATE_XML_PATH; privateXmlValid = false; } else { LOG.log( Level.WARNING, "#184132: unexpected file change in {0}; possibly deleted project?", f); return; } } fireExternalChange(path); }
@Override public long length() { if (uri == null) return list().size(); // Directory try { @NotNull URI u = new URI(uri); try { int length = u.toURL().openConnection().getContentLength(); if (length >= 0) return length; } catch (IOException e) { LOG.log(Level.SEVERE, "Bad URL", e); } } catch (URISyntaxException e) { LOG.log(Level.SEVERE, "Bad URI", e); } return super.length(); }
/** {@inheritDoc}. */ public String getContentType() { try { return myMessage.getContentType(); } catch (MessagingException e) { LOG.log(Level.SEVERE, "Exception while getting content-type", e); return "text/plain"; } }
private CalculateCoauthorsResearcherProcessor(String researcherURI, String affiliationURI) { super(researcherURI); try { affiliation = store.findAffiliationFor(affiliationURI); } catch (Exception e) { LOG.log(Level.SEVERE, "Exception finding affiliation" + affiliationURI, e); } }
/** {@inheritDoc}. */ public InputStream getInputStream() throws IOException { try { return (InputStream) myMessage.getContent(); } catch (MessagingException e) { LOG.log(Level.SEVERE, "Exception while getting content", e); return null; } }
/** Thread runner. Calls the synch method. */ public void run() { try { synch(); } catch (Throwable e) { LOG.log( Level.WARNING, "Error while synchronizing rest criteria with " + "session criteria", e); } }
/** Обработчик всех событий помещенных в очередь */ void processEvents() { for (; ; ) { WatchKey key; try { key = watcher.take(); } catch (InterruptedException x) { LOG.log(Level.SEVERE, x.getMessage()); return; } Path dir = keys.get(key); if (dir == null) { LOG.log(Level.SEVERE, "Входной каталог не найден!"); continue; } for (WatchEvent<?> event : key.pollEvents()) { WatchEvent.Kind kind = event.kind(); // TODO - подумать над обработчиком события OVERFLOW if (kind == OVERFLOW) { continue; } WatchEvent<Path> ev = cast(event); Path name = ev.context(); Path child = dir.resolve(name); // логируем событие if (kind == ENTRY_CREATE) { LOG.log(Level.FINEST, "{0}: {1}", new Object[] {event.kind().name(), child}); Runnable worker = new WorkerThread(child); executor.execute(worker); } } boolean valid = key.reset(); if (!valid) { keys.remove(key); if (keys.isEmpty()) { break; } } } }
@Override public void onNext(final FailedTask task) { LOG.log(Level.WARNING, "Task failed: " + task.getId(), task.getReason().orElse(null)); checkMsgOrder(task); if (task.getActiveContext().isPresent()) { task.getActiveContext().get().close(); } }
@Override public void run() { while (true) { try { final U value = queue.take(); handler.onNext(value); SingleThreadStage.this.afterOnNext(); } catch (final InterruptedException e) { if (interrupted.get()) { LOG.log(Level.FINEST, name + " Closing Producer due to interruption"); break; } } catch (final Throwable t) { LOG.log(Level.SEVERE, name + " Exception from event handler", t); throw t; } } }
public boolean afterInsert(final Object key, final Object value, final Object version) throws CacheException { try { return put(key, value, version, null); } catch (TimeoutException e) { LOG.log(Level.FINEST, e.getMessage()); } return false; }
/** {@inheritDoc} */ public final void interrupt() { try { socket.leaveGroup(groupMulticastAddress); } catch (IOException e) { LOG.log(Level.SEVERE, "Error leaving group"); } socket.close(); super.interrupt(); }
public DiskPage page( TreeSegment segment, int pageNumber, ImmutableItemManager<PageId, DiskPage> diskPageReader) throws IOException, InterruptedException { PageId pageId = new PageId(segment.segmentId(), pageNumber); if (LOG.isLoggable(Level.FINE)) { LOG.log(Level.FINE, "read {0}", pageId); } return find(pageId, diskPageReader); }
public synchronized void delete(List<Element> obsolete) { if (!obsolete.isEmpty()) { if (LOG.isLoggable(Level.INFO)) { LOG.log(Level.INFO, "Deleting {0}", obsolete); } this.queue.addAll(obsolete); notify(); } }
@Override public void run() { try { Set<String> serviceNames = serviceMap.keySet(); Map<String, List<RegisterInfo>> eServcieMap = loadBalancer.getNamingService().list(serviceNames); if (eServcieMap == null) { eServcieMap = Collections.emptyMap(); } Iterator<Entry<String, List<RegisterInfo>>> iter = serviceMap.entrySet().iterator(); while (iter.hasNext()) { Entry<String, List<RegisterInfo>> next = iter.next(); String service = next.getKey(); List<RegisterInfo> oldList = next.getValue(); if (oldList == null) { oldList = Collections.emptyList(); } List<RegisterInfo> newList = eServcieMap.get(service); if (newList == null) { newList = Collections.emptyList(); } if (oldList.equals(newList)) { continue; } LOG.log( Level.WARNING, "A new changed list geting from naming service name='" + service + "' " + "value=" + newList); List<RegisterInfo> list = new ArrayList<RegisterInfo>(newList); next.setValue(list); reInit(service, list); } } catch (Exception e) { LOG.log(Level.WARNING, e.getMessage(), e.getCause()); } }
@Override public void onNext(final FailedContext context) { LOG.log( Level.WARNING, "Context failed: " + context.getId(), context.getReason().orElse(null)); checkMsgOrder(context); // if (context.getParentContext().isPresent()) { // context.getParentContext().get().close(); // } }
/* * (non-Javadoc) * @see * com.almende.eve.state.StateService#delete(com.almende.eve.state.State) */ @Override public void delete(final State instance, final Boolean instanceOnly) { if (!instanceOnly) { try { getCollection().remove("{_id: #}", instance.getId()); } catch (final Exception e) { LOG.log(Level.WARNING, "delete error", e); } } }
@Override public void onClose(final int code, final String reason) { LOG.log(Level.FINE, "WebSocket onClose {0}/{1}", new Object[] {code, reason}); Socket.this.webSocket = null; scheduleReconnectTimer(); for (final ISocketCloseCallback callback : socketCloseCallbacks) { callback.onClose(); } }
@Override public void startProgramUse(GL2 gl) { if (linkedProgram == 0 || linkedShader == 0) { LOG.log(Level.WARNING, "No Shader-Program linked"); } else { gl.glUseProgram(linkedProgram); UniformUtil.setUniform1i(gl, linkedShader, UNIFORM_NAME_SAMPLER0, 0); gl.glValidateProgram(linkedProgram); } }