コード例 #1
0
  public static void main(String[] args) throws Exception {
    ServerOptions options = ServerOptions.parseCommandLine(args);
    if (options == null) return;
    info(options);

    ThrottlingController throttlingController = ThrottlingController.create();
    final Eventloop eventloop =
        Eventloop.create()
            .withThrottlingController(throttlingController)
            .withFatalErrorHandler(rethrowOnAnyError());

    final HttpThrottlingServer server = new HttpThrottlingServer(eventloop, options);

    MBeanServer mbeanServer = ManagementFactory.getPlatformMBeanServer();
    DynamicMBeanFactory mBeanFactory = JmxMBeans.factory();
    mbeanServer.registerMBean(
        mBeanFactory.createFor(asList(eventloop), true),
        new ObjectName(Eventloop.class.getPackage().getName() + ":type=Eventloop"));
    mbeanServer.registerMBean(
        ByteBufPool.getStats(),
        new ObjectName(ByteBufPool.class.getPackage().getName() + ":type=ByteBufPool"));
    mbeanServer.registerMBean(
        mBeanFactory.createFor(asList(throttlingController), true),
        new ObjectName(
            ThrottlingController.class.getPackage().getName() + ":type=ThrottlingController"));
    server.start();

    eventloop.run();
  }
コード例 #2
0
 private void tryCommit() {
   logger.trace("tryCommit called.");
   if (commitCallbacks != 0 || logCallbacks != 0) {
     logger.trace(
         "Exiting tryCommit. Commit callbacks: {}. Log callbacks: {}",
         commitCallbacks,
         logCallbacks);
     return;
   }
   eventloop.post(
       new Runnable() {
         @Override
         public void run() {
           callback.onCommit(log, oldPositions, newPositions, newChunks);
         }
       });
 }