Example usage for org.apache.commons.lang3.builder ReflectionToStringBuilder toString

List of usage examples for org.apache.commons.lang3.builder ReflectionToStringBuilder toString

Introduction

In this page you can find the example usage for org.apache.commons.lang3.builder ReflectionToStringBuilder toString.

Prototype

public static String toString(final Object object) 

Source Link

Document

Builds a toString value using the default ToStringStyle through reflection.

Usage

From source file:org.apache.pulsar.broker.PulsarService.java

/**
 * Start the pulsar service instance./*from ww  w. java  2  s . c o  m*/
 */
public void start() throws PulsarServerException {
    mutex.lock();

    LOG.info("Starting Pulsar Broker service; version: '{}'",
            (brokerVersion != null ? brokerVersion : "unknown"));
    LOG.info("Git Revision {}", PulsarBrokerVersionStringUtils.getGitSha());
    LOG.info("Built by {} on {} at {}", PulsarBrokerVersionStringUtils.getBuildUser(),
            PulsarBrokerVersionStringUtils.getBuildHost(), PulsarBrokerVersionStringUtils.getBuildTime());

    try {
        if (state != State.Init) {
            throw new PulsarServerException("Cannot start the service once it was stopped");
        }

        // Now we are ready to start services
        localZooKeeperConnectionProvider = new LocalZooKeeperConnectionService(getZooKeeperClientFactory(),
                config.getZookeeperServers(), config.getZooKeeperSessionTimeoutMillis());
        localZooKeeperConnectionProvider.start(shutdownService);

        // Initialize and start service to access configuration repository.
        this.startZkCacheService();

        this.bkClientFactory = newBookKeeperClientFactory();
        managedLedgerClientFactory = new ManagedLedgerClientFactory(config, getZkClient(), bkClientFactory);

        this.brokerService = new BrokerService(this);

        // Start load management service (even if load balancing is disabled)
        this.loadManager.set(LoadManager.create(this));

        // Start the leader election service
        startLeaderElectionService();

        // needs load management service
        this.startNamespaceService();

        this.offloader = createManagedLedgerOffloader(this.getConfiguration());

        brokerService.start();

        this.webService = new WebService(this);
        Map<String, Object> attributeMap = Maps.newHashMap();
        attributeMap.put(WebService.ATTRIBUTE_PULSAR_NAME, this);
        Map<String, Object> vipAttributeMap = Maps.newHashMap();
        vipAttributeMap.put(VipStatus.ATTRIBUTE_STATUS_FILE_PATH, this.config.getStatusFilePath());
        vipAttributeMap.put(VipStatus.ATTRIBUTE_IS_READY_PROBE, new Supplier<Boolean>() {
            @Override
            public Boolean get() {
                // Ensure the VIP status is only visible when the broker is fully initialized
                return state == State.Started;
            }
        });
        this.webService.addRestResources("/", VipStatus.class.getPackage().getName(), false, vipAttributeMap);
        this.webService.addRestResources("/", "org.apache.pulsar.broker.web", false, attributeMap);
        this.webService.addRestResources("/admin", "org.apache.pulsar.broker.admin.v1", true, attributeMap);
        this.webService.addRestResources("/admin/v2", "org.apache.pulsar.broker.admin.v2", true, attributeMap);
        this.webService.addRestResources("/admin/v3", "org.apache.pulsar.broker.admin.v3", true, attributeMap);
        this.webService.addRestResources("/lookup", "org.apache.pulsar.broker.lookup", true, attributeMap);

        this.webService.addServlet("/metrics",
                new ServletHolder(
                        new PrometheusMetricsServlet(this, config.isExposeTopicLevelMetricsInPrometheus(),
                                config.isExposeConsumerLevelMetricsInPrometheus())),
                false, attributeMap);

        if (config.isWebSocketServiceEnabled()) {
            // Use local broker address to avoid different IP address when using a VIP for service discovery
            this.webSocketService = new WebSocketService(new ClusterData(webServiceAddress,
                    webServiceAddressTls, brokerServiceUrl, brokerServiceUrlTls), config);
            this.webSocketService.start();

            final WebSocketServlet producerWebSocketServlet = new WebSocketProducerServlet(webSocketService);
            this.webService.addServlet(WebSocketProducerServlet.SERVLET_PATH,
                    new ServletHolder(producerWebSocketServlet), true, attributeMap);
            this.webService.addServlet(WebSocketProducerServlet.SERVLET_PATH_V2,
                    new ServletHolder(producerWebSocketServlet), true, attributeMap);

            final WebSocketServlet consumerWebSocketServlet = new WebSocketConsumerServlet(webSocketService);
            this.webService.addServlet(WebSocketConsumerServlet.SERVLET_PATH,
                    new ServletHolder(consumerWebSocketServlet), true, attributeMap);
            this.webService.addServlet(WebSocketConsumerServlet.SERVLET_PATH_V2,
                    new ServletHolder(consumerWebSocketServlet), true, attributeMap);

            final WebSocketServlet readerWebSocketServlet = new WebSocketReaderServlet(webSocketService);
            this.webService.addServlet(WebSocketReaderServlet.SERVLET_PATH,
                    new ServletHolder(readerWebSocketServlet), true, attributeMap);
            this.webService.addServlet(WebSocketReaderServlet.SERVLET_PATH_V2,
                    new ServletHolder(readerWebSocketServlet), true, attributeMap);
        }

        if (LOG.isDebugEnabled()) {
            LOG.debug("Attempting to add static directory");
        }
        this.webService.addStaticResources("/static", "/static");

        // Register heartbeat and bootstrap namespaces.
        this.nsservice.registerBootstrapNamespaces();

        schemaRegistryService = SchemaRegistryService.create(this);

        webService.start();

        this.metricsGenerator = new MetricsGenerator(this);

        // By starting the Load manager service, the broker will also become visible
        // to the rest of the broker by creating the registration z-node. This needs
        // to be done only when the broker is fully operative.
        this.startLoadManagementService();

        state = State.Started;

        acquireSLANamespace();

        // start function worker service if necessary
        this.startWorkerService();

        LOG.info(
                "messaging service is ready, bootstrap service on port={}, broker url={}, cluster={}, configs={}",
                config.getWebServicePort().get(), brokerServiceUrl, config.getClusterName(),
                ReflectionToStringBuilder.toString(config));
    } catch (Exception e) {
        LOG.error(e.getMessage(), e);
        throw new PulsarServerException(e);
    } finally {
        mutex.unlock();
    }
}

From source file:org.jeecgframework.poi.test.excel.read.ExcelVerifyTest.java

@Test
public void basetest() {
    try {/*from www. j a  v  a  2 s.  c o m*/
        ImportParams params = new ImportParams();
        params.setNeedVerfiy(true);
        ExcelImportResult<ExcelVerifyEntity> result = ExcelImportUtil.importExcelVerify(
                new File(PoiPublicUtil.getWebRootPath("import/verfiy.xlsx")), ExcelVerifyEntity.class, params);
        FileOutputStream fos = new FileOutputStream("D:/excel/ExcelVerifyTest.basetest.xlsx");
        result.getWorkbook().write(fos);
        fos.close();
        for (int i = 0; i < result.getList().size(); i++) {
            System.out.println(ReflectionToStringBuilder.toString(result.getList().get(i)));
        }
        Assert.assertTrue(result.getList().size() == 1);
        Assert.assertTrue(result.isVerfiyFail());
    } catch (Exception e) {
        LOGGER.error(e.getMessage(), e);
    }
}

From source file:org.jeecgframework.poi.test.excel.read.ExcelVerifyTest.java

@Test
public void baseModetest() {
    try {/*from ww w. ja v a2  s.co m*/
        ImportParams params = new ImportParams();
        params.setNeedVerfiy(true);
        ExcelImportResult<ExcelVerifyEntityOfMode> result = ExcelImportUtil.importExcelVerify(
                new File(PoiPublicUtil.getWebRootPath("import/verfiy.xlsx")), ExcelVerifyEntityOfMode.class,
                params);
        FileOutputStream fos = new FileOutputStream("D:/excel/baseModetest.xlsx");
        result.getWorkbook().write(fos);
        fos.close();
        for (int i = 0; i < result.getList().size(); i++) {
            System.out.println(ReflectionToStringBuilder.toString(result.getList().get(i)));
        }
        Assert.assertTrue(result.getList().size() == 4);
    } catch (Exception e) {
        LOGGER.error(e.getMessage(), e);
    }
}

From source file:org.jeecgframework.poi.test.excel.read.ExcelVerifyTest.java

@Test
public void baseHanldertest() {
    try {// w  w  w. j  a v  a 2  s  .  c  om
        ImportParams params = new ImportParams();
        params.setVerifyHanlder(new ExcelVerifyHandlerImpl());
        ExcelImportResult<ExcelVerifyEntityOfMode> result = ExcelImportUtil.importExcelVerify(
                new File(PoiPublicUtil.getWebRootPath("import/verfiy.xlsx")), ExcelVerifyEntityOfMode.class,
                params);
        FileOutputStream fos = new FileOutputStream("D:/excel/baseHanldertest.xlsx");
        result.getWorkbook().write(fos);
        fos.close();
        for (int i = 0; i < result.getList().size(); i++) {
            System.out.println(ReflectionToStringBuilder.toString(result.getList().get(i)));
        }
        Assert.assertTrue(result.getList().size() == 4);
    } catch (Exception e) {
        LOGGER.error(e.getMessage(), e);
    }
}

From source file:org.jeecgframework.poi.test.excel.read.ExcelVerifyTest.java

@Test
public void combinedVerificationTest() {
    try {/* w  ww  .  jav a2 s  .c  o  m*/
        ImportParams params = new ImportParams();
        params.setVerifyHanlder(new ExcelVerifyHandlerImpl());
        params.setNeedVerfiy(true);
        ExcelImportResult<ExcelVerifyEntityOfMode> result = ExcelImportUtil.importExcelVerify(
                new File(PoiPublicUtil.getWebRootPath("import/verfiy.xlsx")), ExcelVerifyEntityOfMode.class,
                params);
        FileOutputStream fos = new FileOutputStream("D:/excel/combinedVerificationTest.xlsx");
        result.getWorkbook().write(fos);
        fos.close();
        for (int i = 0; i < result.getList().size(); i++) {
            System.out.println(ReflectionToStringBuilder.toString(result.getList().get(i)));
        }
        Assert.assertTrue(result.getList().size() == 4);
    } catch (Exception e) {
        LOGGER.error(e.getMessage(), e);
    }
}

From source file:org.opendaylight.controller.hosttracker.hostAware.HostNodeConnector.java

@Override
public String toString() {
    return "HostNodeConnector[" + ReflectionToStringBuilder.toString(this) + "]";
}

From source file:org.opendaylight.controller.protocol_plugin.openflow.vendorextension.v6extension.V6FlowMod.java

/**
 * Prints the contents of V6FlowMod in a string format.
 *///from   ww  w.  j  a  va  2  s . c  om
@Override
public String toString() {
    return "V6FlowMod[" + ReflectionToStringBuilder.toString(this) + "]";
}

From source file:org.opendaylight.controller.protocol_plugin.openflow.vendorextension.v6extension.V6Match.java

@Override
public String toString() {
    return "V6Match[" + ReflectionToStringBuilder.toString(this) + "]";
}

From source file:org.opendaylight.controller.protocol_plugin.openflow.vendorextension.v6extension.V6StatsReply.java

@Override
public String toString() {
    return "V6StatsReply[" + ReflectionToStringBuilder.toString(this) + "]";
}

From source file:org.opendaylight.controller.protocol_plugin.openflow.vendorextension.v6extension.V6StatsRequest.java

@Override
public String toString() {
    return "V6StatsRequest[" + ReflectionToStringBuilder.toString(this) + "]";
}