Search in sources :

Example 1 with ServiceBuilderConfig

use of io.pravega.segmentstore.server.store.ServiceBuilderConfig in project pravega by pravega.

the class SelfTestRunner method main.

public static void main(String[] args) throws Exception {
    Properties shortcuts = Shortcuts.extract(System.getProperties());
    if (shortcuts.size() == 0 && !System.getProperties().containsKey(TestConfig.CONFIG_FILE_PROPERTY_NAME)) {
        printUsage();
        return;
    }
    // Load config & setup logging.
    ServiceBuilderConfig builderConfig = getConfig(shortcuts);
    TestConfig testConfig = builderConfig.getConfig(TestConfig::builder);
    setupLogging(testConfig);
    // Create a new SelfTest.
    @Cleanup SelfTest test = new SelfTest(testConfig, builderConfig);
    // Start the test.
    test.startAsync().awaitRunning(STARTUP_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS);
    // Wait for the test to finish.
    test.awaitFinished().join();
    if (testConfig.isPauseBeforeExit()) {
        System.out.println("Services are still running. Press any key to exit ...");
        System.in.read();
    }
    // Make sure the test is stopped.
    test.stopAsync().awaitTerminated();
}
Also used : ServiceBuilderConfig(io.pravega.segmentstore.server.store.ServiceBuilderConfig) Properties(java.util.Properties) Cleanup(lombok.Cleanup)

Example 2 with ServiceBuilderConfig

use of io.pravega.segmentstore.server.store.ServiceBuilderConfig in project pravega by pravega.

the class SelfTestRunner method getConfig.

/**
 * Gets a ServiceBuilderConfig containing test-related and SegmentStore-related configuration, using the following
 * priority order (low to high):
 * 1. Hardcoded defaults.
 * 2. Config file.
 * 3. System Properties.
 * 4. Explicit overrides (as passed in via an argument).
 *
 * @param overrides Explicit overrides.
 */
private static ServiceBuilderConfig getConfig(Properties overrides) throws IOException {
    // 1. Hardcoded defaults.
    ServiceBuilderConfig.Builder b = getDefaultServiceBuilderConfig();
    // 2. File-based config (overriding defaults).
    File configFile = new File(System.getProperty(TestConfig.CONFIG_FILE_PROPERTY_NAME, TestConfig.DEFAULT_CONFIG_FILE_NAME));
    if (configFile.exists()) {
        b.include(System.getProperty(TestConfig.CONFIG_FILE_PROPERTY_NAME, TestConfig.DEFAULT_CONFIG_FILE_NAME));
    }
    // 3. System Property-based config (overriding defaults and File-based config).
    b.include(System.getProperties());
    // 4. Apply explicit overrides.
    b.include(overrides);
    // 5. Cross-apply common configuration that must be the same on all fronts.
    val testConfig = b.build().getConfig(TestConfig::builder);
    int bkWriteQuorum = Math.min(3, testConfig.getBookieCount());
    b.include(ServiceConfig.builder().with(ServiceConfig.CONTAINER_COUNT, testConfig.getContainerCount()));
    b.include(BookKeeperConfig.builder().with(BookKeeperConfig.ZK_ADDRESS, TestConfig.LOCALHOST + ":" + testConfig.getZkPort()).with(BookKeeperConfig.BK_ACK_QUORUM_SIZE, bkWriteQuorum).with(BookKeeperConfig.BK_WRITE_QUORUM_SIZE, bkWriteQuorum).with(BookKeeperConfig.BK_ENSEMBLE_SIZE, bkWriteQuorum));
    if (testConfig.isMetricsEnabled()) {
        b.include(MetricsConfig.builder().with(MetricsConfig.ENABLE_STATISTICS, true).with(MetricsConfig.ENABLE_CSV_REPORTER, true).with(MetricsConfig.OUTPUT_FREQUENCY, 1).with(MetricsConfig.CSV_ENDPOINT, testConfig.getComponentMetricsPath("segmentstore", 0)));
    }
    return b.build();
}
Also used : lombok.val(lombok.val) ServiceBuilderConfig(io.pravega.segmentstore.server.store.ServiceBuilderConfig) File(java.io.File)

Example 3 with ServiceBuilderConfig

use of io.pravega.segmentstore.server.store.ServiceBuilderConfig in project pravega by pravega.

the class LocalPravegaEmulator method main.

public static void main(String[] args) {
    try {
        ServiceBuilderConfig config = ServiceBuilderConfig.builder().include(System.getProperties()).build();
        SingleNodeConfig conf = config.getConfig(SingleNodeConfig::builder);
        final LocalPravegaEmulator localPravega = LocalPravegaEmulator.builder().controllerPort(conf.getControllerPort()).segmentStorePort(conf.getSegmentStorePort()).zkPort(conf.getZkPort()).restServerPort(conf.getRestServerPort()).enableAuth(true).enableTls(true).build();
        Runtime.getRuntime().addShutdownHook(new Thread() {

            @Override
            public void run() {
                try {
                    localPravega.close();
                    System.out.println("ByeBye!");
                } catch (Exception e) {
                    // do nothing
                    log.warn("Exception running local Pravega emulator: " + e.getMessage());
                }
            }
        });
        log.info("Starting Pravega Emulator with ports: ZK port {}, controllerPort {}, SegmentStorePort {}", conf.getZkPort(), conf.getControllerPort(), conf.getSegmentStorePort());
        localPravega.start();
        System.out.println(String.format("Pravega Sandbox is running locally now. You could access it at %s:%d", "127.0.0.1", conf.getControllerPort()));
    } catch (Exception ex) {
        log.error("Exception occurred running emulator", ex);
        System.exit(1);
    }
}
Also used : ServiceBuilderConfig(io.pravega.segmentstore.server.store.ServiceBuilderConfig)

Example 4 with ServiceBuilderConfig

use of io.pravega.segmentstore.server.store.ServiceBuilderConfig in project pravega by pravega.

the class InProcPravegaClusterTest method setUp.

@Before
public void setUp() throws Exception {
    ServiceBuilderConfig config = ServiceBuilderConfig.builder().include(System.getProperties()).build();
    SingleNodeConfig conf = config.getConfig(SingleNodeConfig::builder);
    localPravega = LocalPravegaEmulator.builder().controllerPort(TestUtils.getAvailableListenPort()).segmentStorePort(TestUtils.getAvailableListenPort()).zkPort(TestUtils.getAvailableListenPort()).restServerPort(TestUtils.getAvailableListenPort()).enableAuth(authEnabled).enableTls(tlsEnabled).build();
    localPravega.start();
}
Also used : ServiceBuilderConfig(io.pravega.segmentstore.server.store.ServiceBuilderConfig) Before(org.junit.Before)

Example 5 with ServiceBuilderConfig

use of io.pravega.segmentstore.server.store.ServiceBuilderConfig in project pravega by pravega.

the class ServiceStarter method main.

// endregion
// region main()
public static void main(String[] args) throws Exception {
    AtomicReference<ServiceStarter> serviceStarter = new AtomicReference<>();
    try {
        System.err.println(System.getProperty(ServiceBuilderConfig.CONFIG_FILE_PROPERTY_NAME, "config.properties"));
        // Load up the ServiceBuilderConfig, using this priority order (lowest to highest):
        // 1. Configuration file (either default or specified via SystemProperties)
        // 2. System Properties overrides (these will be passed in via the command line or inherited from the JVM)
        ServiceBuilderConfig config = ServiceBuilderConfig.builder().include(System.getProperty(ServiceBuilderConfig.CONFIG_FILE_PROPERTY_NAME, "config.properties")).include(System.getProperties()).build();
        // For debugging purposes, it may be useful to know the non-default values for configurations being used.
        // This will unfortunately include all System Properties as well, but knowing those can be useful too sometimes.
        log.info("Segment store configuration:");
        config.forEach((key, value) -> log.info("{} = {}", key, value));
        serviceStarter.set(new ServiceStarter(config));
    } catch (Throwable e) {
        log.error("Could not create a Service with default config, Aborting.", e);
        System.exit(1);
    }
    try {
        serviceStarter.get().start();
        Runtime.getRuntime().addShutdownHook(new Thread(() -> {
            log.info("Caught interrupt signal...");
            serviceStarter.get().shutdown();
        }));
        Thread.sleep(Long.MAX_VALUE);
    } catch (InterruptedException ex) {
        log.info("Caught interrupt signal...");
    } finally {
        serviceStarter.get().shutdown();
    }
}
Also used : ServiceBuilderConfig(io.pravega.segmentstore.server.store.ServiceBuilderConfig) AtomicReference(java.util.concurrent.atomic.AtomicReference)

Aggregations

ServiceBuilderConfig (io.pravega.segmentstore.server.store.ServiceBuilderConfig)5 File (java.io.File)1 Properties (java.util.Properties)1 AtomicReference (java.util.concurrent.atomic.AtomicReference)1 Cleanup (lombok.Cleanup)1 lombok.val (lombok.val)1 Before (org.junit.Before)1