org.eclipse.jetty.server.ConnectionLimit Java Examples

The following examples show how to use org.eclipse.jetty.server.ConnectionLimit. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WebServer.java    From hop with Apache License 2.0 6 votes vote down vote up
/**
 * Set up jetty options to the connector
 *
 * @param connector
 */
protected void setupJettyOptions( ServerConnector connector ) {
  LowResourceMonitor lowResourceMonitor = new LowResourceMonitor( server );
  if ( validProperty( Const.HOP_SERVER_JETTY_ACCEPTORS ) ) {
    server.addBean( new ConnectionLimit( Integer.parseInt( System.getProperty( Const.HOP_SERVER_JETTY_ACCEPTORS ) ) ) );
    log.logBasic(
      BaseMessages.getString( PKG, "WebServer.Log.ConfigOptions", "acceptors", connector.getAcceptors() ) );
  }

  if ( validProperty( Const.HOP_SERVER_JETTY_ACCEPT_QUEUE_SIZE ) ) {
    connector
      .setAcceptQueueSize( Integer.parseInt( System.getProperty( Const.HOP_SERVER_JETTY_ACCEPT_QUEUE_SIZE ) ) );
    log.logBasic( BaseMessages
      .getString( PKG, "WebServer.Log.ConfigOptions", "acceptQueueSize", connector.getAcceptQueueSize() ) );
  }

  if ( validProperty( Const.HOP_SERVER_JETTY_RES_MAX_IDLE_TIME ) ) {
    connector.setIdleTimeout( Integer.parseInt( System.getProperty( Const.HOP_SERVER_JETTY_RES_MAX_IDLE_TIME ) ) );
    log.logBasic( BaseMessages.getString( PKG, "WebServer.Log.ConfigOptions", "lowResourcesMaxIdleTime",
      connector.getIdleTimeout() ) );
  }
}
 
Example #2
Source File: ConfirmedHttpApiService.java    From gsc-core with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public void start() {
    try {
        server = new Server(port);
        ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
        context.setContextPath("/");
        server.setHandler(context);

        // same as Start
        context.addServlet(new ServletHolder(accountOnConfirmedServlet), "/walletconfirmed/getaccount");
        context.addServlet(new ServletHolder(listWitnessesOnConfirmedServlet),
                "/walletconfirmed/listwitnesses");
        context.addServlet(new ServletHolder(getAssetIssueListOnConfirmedServlet),
                "/walletconfirmed/getassetissuelist");
        context.addServlet(new ServletHolder(getPaginatedAssetIssueListOnConfirmedServlet),
                "/walletconfirmed/getpaginatedassetissuelist");
        context.addServlet(new ServletHolder(getAssetIssueByNameOnConfirmedServlet),
                "/walletconfirmed/getassetissuebyname");
        context.addServlet(new ServletHolder(getAssetIssueByIdOnConfirmedServlet),
                "/walletconfirmed/getassetissuebyid");
        context.addServlet(new ServletHolder(getAssetIssueListByNameOnConfirmedServlet),
                "/walletconfirmed/getassetissuelistbyname");
        context.addServlet(new ServletHolder(getNowBlockOnConfirmedServlet),
                "/walletconfirmed/getnowblock");
        context.addServlet(new ServletHolder(getBlockByNumOnConfirmedServlet),
                "/walletconfirmed/getblockbynum");
        context.addServlet(new ServletHolder(getDelegatedResourceOnConfirmedServlet),
                "/walletconfirmed/getdelegatedresource");
        context.addServlet(new ServletHolder(getDelegatedResourceAccountIndexOnConfirmedServlet),
                "/walletconfirmed/getdelegatedresourceaccountindex");
        context.addServlet(new ServletHolder(getExchangeByIdOnConfirmedServlet),
                "/walletconfirmed/getexchangebyid");
        context.addServlet(new ServletHolder(listExchangesOnConfirmedServlet),
                "/walletconfirmed/listexchanges");
        context.addServlet(new ServletHolder(getAccountByIdOnConfirmedServlet),
                "/walletconfirmed/getaccountbyid");
        context.addServlet(new ServletHolder(getBlockByIdOnConfirmedServlet),
                "/walletconfirmed/getblockbyid");
        context.addServlet(new ServletHolder(getBlockByLimitNextOnConfirmedServlet),
                "/walletconfirmed/getblockbylimitnext");
        context.addServlet(new ServletHolder(getBlockByLatestNumOnConfirmedServlet),
                "/walletconfirmed/getblockbylatestnum");
        // only for ConfirmedNode
        context.addServlet(new ServletHolder(getTransactionByIdOnConfirmedServlet),
                "/walletconfirmed/gettransactionbyid");
        context.addServlet(new ServletHolder(getTransactionInfoByIdOnConfirmedServlet),
                "/walletconfirmed/gettransactioninfobyid");

        context.addServlet(new ServletHolder(getTransactionCountByBlockNumOnConfirmedServlet),
                "/walletconfirmed/gettransactioncountbyblocknum");

        context.addServlet(new ServletHolder(getNodeInfoOnConfirmedServlet), "/wallet/getnodeinfo");
        int maxHttpConnectNumber = Args.getInstance().getMaxHttpConnectNumber();
        if (maxHttpConnectNumber > 0) {
            server.addBean(new ConnectionLimit(maxHttpConnectNumber, server));
        }
        server.start();
    } catch (Exception e) {
        logger.debug("IOException: {}", e.getMessage());
    }
}
 
Example #3
Source File: ConfirmedHttpApiService.java    From gsc-core with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public void start() {
    Args args = Args.getInstance();
    try {
        server = new Server(port);
        ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
        context.setContextPath("/");
        server.setHandler(context);

        // same as Start
        context.addServlet(new ServletHolder(getAccountServlet), "/walletconfirmed/getaccount");
        context.addServlet(new ServletHolder(listWitnessesServlet), "/walletconfirmed/listwitnesses");
        context.addServlet(new ServletHolder(getAssetIssueListServlet),
                "/walletconfirmed/getassetissuelist");
        context.addServlet(new ServletHolder(getPaginatedAssetIssueListServlet),
                "/walletconfirmed/getpaginatedassetissuelist");
        context.addServlet(new ServletHolder(getAssetIssueByNameServlet),
                "/walletconfirmed/getassetissuebyname");
        context.addServlet(new ServletHolder(getAssetIssueByIdServlet),
                "/walletconfirmed/getassetissuebyid");
        context.addServlet(new ServletHolder(getAssetIssueListByNameServlet),
                "/walletconfirmed/getassetissuelistbyname");
        context.addServlet(new ServletHolder(getNowBlockServlet), "/walletconfirmed/getnowblock");
        context.addServlet(new ServletHolder(getBlockByNumServlet), "/walletconfirmed/getblockbynum");
        context.addServlet(new ServletHolder(getDelegatedResourceServlet),
                "/walletconfirmed/getdelegatedresource");
        context.addServlet(new ServletHolder(getDelegatedResourceAccountIndexServlet),
                "/walletconfirmed/getdelegatedresourceaccountindex");
        context
                .addServlet(new ServletHolder(getExchangeByIdServlet),
                        "/walletconfirmed/getexchangebyid");
        context.addServlet(new ServletHolder(listExchangesServlet),
                "/walletconfirmed/listexchanges");

        context.addServlet(new ServletHolder(getAccountByIdServlet),
                "/walletconfirmed/getaccountbyid");
        context.addServlet(new ServletHolder(getBlockByIdServlet),
                "/walletconfirmed/getblockbyid");
        context.addServlet(new ServletHolder(getBlockByLimitNextServlet),
                "/walletconfirmed/getblockbylimitnext");
        context.addServlet(new ServletHolder(getBlockByLatestNumServlet),
                "/walletconfirmed/getblockbylatestnum");

        // only for ConfirmedNode
        context.addServlet(new ServletHolder(getTransactionByIdServlet),
                "/walletconfirmed/gettransactionbyid");

        context
                .addServlet(new ServletHolder(getTransactionInfoByIdServlet),
                        "/walletconfirmed/gettransactioninfobyid");
        context
                .addServlet(new ServletHolder(getTransactionCountByBlockNumServlet),
                        "/walletconfirmed/gettransactioncountbyblocknum");
        // for extension api
        if (args.isWalletExtensionApi()) {
            context.addServlet(new ServletHolder(getTransactionsFromThisServlet),
                    "/walletextension/gettransactionsfromthis");
            context
                    .addServlet(new ServletHolder(getTransactionsToThisServlet),
                            "/walletextension/gettransactionstothis");
        }
        context.addServlet(new ServletHolder(getNodeInfoServlet), "/wallet/getnodeinfo");
        int maxHttpConnectNumber = Args.getInstance().getMaxHttpConnectNumber();
        if (maxHttpConnectNumber > 0) {
            server.addBean(new ConnectionLimit(maxHttpConnectNumber, server));
        }

        server.start();
    } catch (Exception e) {
        logger.debug("IOException: {}", e.getMessage());
    }
}