Example #1
0
 @Override
 public void unregistered(SelectionKey key) {
   serverHelperExecutor.shutdown();
   storageHelperExecutor.shutdown();
   try {
     serverHelperExecutor.awaitTermination(5000, TimeUnit.MILLISECONDS);
   } catch (InterruptedException ex) {
     logger.debug("Executor Termination", ex);
   }
   logger.info("Server stopped listening at {}", address);
 }
Example #2
0
  private void handleResetRequest(
      ResetRequestTuple request, final AbstractLengthPrependerClient ctx) throws IOException {
    DataList dl;
    dl = publisherBuffers.remove(request.getIdentifier());

    byte[] message;
    if (dl == null) {
      message = ("Invalid identifier '" + request.getIdentifier() + "'").getBytes();
    } else {
      AbstractLengthPrependerClient channel = publisherChannels.remove(request.getIdentifier());
      if (channel != null) {
        eventloop.disconnect(channel);
      }
      dl.reset();
      message = ("Request sent for processing: " + request).getBytes();
    }

    final byte[] tuple = PayloadTuple.getSerializedTuple(0, message.length);
    System.arraycopy(message, 0, tuple, tuple.length - message.length, message.length);
    serverHelperExecutor.submit(
        new Runnable() {
          @Override
          public void run() {
            ctx.write(tuple);
            eventloop.disconnect(ctx);
          }
        });
  }