Refine search
public void init() throws Exception { super.init(); dest_addr=InetAddress.getByName(dest); if(log.isDebugEnabled()) log.debug("listening on " + bind_port); }
/** * Required to deserialize the object when read in from the wire * * * * @param in * @throws Exception */ public void readFrom(DataInput in) throws Exception { if (log.isDebugEnabled()) { log.debug("SimpleToken readFrom()"); } this.auth_value = Bits.readString(in); }
/** * Required to serialize the object to pass across the wire * * * * @param out * @throws Exception */ public void writeTo(DataOutput out) throws Exception { if (log.isDebugEnabled()) { log.debug("SimpleToken writeTo()"); } Bits.writeString(this.auth_value,out); }
private void onFlushReconcileOK(Message msg) { if (log.isDebugEnabled()) log.debug(localAddress + ": received reconcile ok from " + msg.getSrc()); synchronized (sharedLock) { reconcileOks.add(msg.getSrc()); if (reconcileOks.size() >= flushMembers.size()) { flush_promise.setResult(SUCCESS_START_FLUSH); if (log.isDebugEnabled()) log.debug(localAddress + ": all FLUSH_RECONCILE_OK received"); } } }
private void logException(String msg, Exception e) { if (log.isDebugEnabled()) { log.debug(msg, e); } else if (log.isWarnEnabled()) { log.warn("%s. Error is %s", msg, e.getLocalizedMessage()); } }
public void stop() { if(log.isDebugEnabled()) log.debug("closing sockets and stopping threads"); server.stop(); //not needed, but just in case super.stop(); }
private void onStopFlush() { if (stats && startFlushTime > 0) { long stopFlushTime = System.currentTimeMillis(); totalTimeInFlush += (stopFlushTime - startFlushTime); if (numberOfFlushes > 0) { averageFlushDuration = totalTimeInFlush / (double) numberOfFlushes; } startFlushTime = 0; } if (log.isDebugEnabled()) log.debug(localAddress + ": received STOP_FLUSH, unblocking FLUSH.down() and sending UNBLOCK up"); resetForNextFlush(); if (sentUnblock.compareAndSet(false, true)) { // ensures that we do not repeat unblock event sendUnBlockUpToChannel(); } }
protected void handleView(View view) { view_size=view.size(); Address tmp=Util.pickNext(view.getMembers(), local_addr); if(tmp != null && !tmp.equals(local_addr)) { next=tmp; if(log.isDebugEnabled()) log.debug("next=" + next); } }
if (log.isDebugEnabled()) log.debug("Interrupted while handing off task"); Thread.currentThread().interrupt(); received = false; if (log.isDebugEnabled()) log.debug("Consumer " + threadId + " has been interrupted, " + "must retry to submit elsewhere"); received = false; if (log.isDebugEnabled()) log.debug("Timeout waiting to hand off to barrier, consumer " + threadId + " must be slow"); if (log.isDebugEnabled()) log.debug("Run rejected not able to pass off to consumer");
public void stop() { if(log.isDebugEnabled()) log.debug("closing server socket " + srv_sock.getLocalSocketAddress()); if(acceptor != null && acceptor.isAlive()) { try { // this will terminate thread, peer will receive SocketException (socket close) getSocketFactory().close(srv_sock); } catch(Exception ex) { } } synchronized(connections) { connections.forEach(Connection::stop); connections.clear(); } acceptor=null; super.stop(); }
public void run() { if(log.isDebugEnabled()) log.debug(local_addr + ": StateProviderAcceptor listening at " + getServerSocketAddress()); while(running) { try { final Socket socket=serverSocket.accept(); try { pool.execute(() -> process(socket)); } catch(RejectedExecutionException rejected) { Util.close(socket); } } catch(Throwable e) { if(serverSocket.isClosed()) running=false; } } }
private void blockMessageDuringFlush() { boolean shouldSuspendByItself = false; blockMutex.lock(); try { while (isBlockingFlushDown) { if (log.isDebugEnabled()) log.debug(localAddress + ": blocking for " + (timeout <= 0 ? "ever" : timeout + "ms")); if(timeout <= 0) { notBlockedDown.await(); } else { shouldSuspendByItself = !notBlockedDown.await(timeout, TimeUnit.MILLISECONDS); } if (shouldSuspendByItself) { isBlockingFlushDown = false; log.warn(localAddress + ": unblocking after " + timeout + "ms"); flush_promise.setResult(new FlushStartResult(Boolean.TRUE,null)); notBlockedDown.signalAll(); } } } catch (InterruptedException e) { Thread.currentThread().interrupt(); } finally { blockMutex.unlock(); } }
public boolean authenticate(AuthToken token, Message msg) { if ((token != null) && (token instanceof SimpleToken)) { // Found a valid Token to authenticate against SimpleToken serverToken = (SimpleToken) token; if ((this.auth_value != null) && (serverToken.auth_value != null) && (this.auth_value.equalsIgnoreCase(serverToken.auth_value))) { // validated if (log.isDebugEnabled()) { log.debug("SimpleToken match"); } return true; } else { // if(log.isWarnEnabled()){ // log.warn("Authentication failed on SimpleToken"); // } return false; } } if (log.isWarnEnabled()) { log.warn("Invalid AuthToken instance - wrong type or null"); } return false; }
protected void process(Socket socket) { OutputStream output=null; try { socket.setSendBufferSize(buffer_size); if(log.isDebugEnabled()) log.debug(local_addr + ": accepted request for state transfer from " + socket.getInetAddress() + ":" + socket.getPort()); DataInput in=new DataInputStream(socket.getInputStream()); Address stateRequester=Util.readAddress(in); output=new BufferedOutputStream(socket.getOutputStream(), buffer_size); getStateFromApplication(stateRequester, output, false); } catch(Throwable e) { if(log.isWarnEnabled()) log.warn(local_addr + ": failed handling request from requester", e); } // getStateFromApplication() is run in the same thread; it closes the output stream, and we close the socket finally { Util.close(socket); } }
private boolean onViewChange(View view) { boolean coordinatorLeft = false; View oldView; synchronized (sharedLock) { suspected.retainAll(view.getMembers()); oldView = currentView; currentView = view; coordinatorLeft = !oldView.getMembers().isEmpty() && !view.getMembers().isEmpty() && !view.containsMember(oldView.getCreator()); } if (log.isDebugEnabled()) log.debug(localAddress + ": installing view " + view); return coordinatorLeft; }
public void start() throws Exception { super.start(); srv_sock=Util.createServerSocket(getSocketFactory(), "jgroups.stomp.srv_sock", bind_addr, port, port+50); if(log.isDebugEnabled()) log.debug("server socket listening on " + srv_sock.getLocalSocketAddress()); if(acceptor == null) { acceptor=getThreadFactory().newThread(this, "STOMP acceptor"); acceptor.setDaemon(true); acceptor.start(); } endpoint=endpoint_addr != null? endpoint_addr : getAddress(); }
protected void handleView(View view) { this.view=view; if(log.isDebugEnabled()) log.debug("view=" + view); List<Address> members=view.getMembers(); Address old_coord=coord; if(!members.isEmpty()) coord=members.get(0); if(Objects.equals(coord, local_addr)) { List<Address> old_backups=backup_coords != null? new ArrayList<>(backup_coords) : null; backup_coords=new CopyOnWriteArrayList<>(Util.pickNext(members, local_addr, num_backups)); // send the current values to all *new* backups List<Address> new_backups=Util.newElements(old_backups,backup_coords); for(Address new_backup: new_backups) { for(Map.Entry<String,VersionedValue> entry: counters.entrySet()) { UpdateRequest update=new UpdateRequest(entry.getKey(), entry.getValue().value, entry.getValue().version); sendRequest(new_backup, update); } } } else backup_coords=null; if(old_coord != null && coord != null && !old_coord.equals(coord) && local_addr.equals(coord)) { discard_requests=true; // set to false when the task is done startReconciliationTask(); } }
return; StringBuilder sb=log.isDebugEnabled()? new StringBuilder("\n[" + local_addr + (merge? " mergeDigest()]\n" : " setDigest()]\n")) .append("existing digest: " + getDigest()).append("\nnew digest: " + digest) : null; if(sb != null) digest_history.add(sb.toString()); if(log.isDebugEnabled()) log.debug(sb.toString());
if(log.isDebugEnabled()) log.debug(sb.toString());
void closeMulticastSocket() { if(mcast_sock != null) { try { if(mcast_addr != null) { mcast_sock.leaveGroup(mcast_addr.getIpAddress()); } getSocketFactory().close(mcast_sock); // this will cause the mcast receiver thread to break out of its loop mcast_sock=null; if(log.isDebugEnabled()) log.debug("multicast socket closed"); } catch(IOException ex) { } mcast_addr=null; } }