Search in sources :

Example 6 with AutoScaleMonitor

use of io.pravega.segmentstore.server.host.stat.AutoScaleMonitor in project pravega by pravega.

the class AppendProcessorAdapter method startUp.

// endregion
// region StoreAdapter Implementation
@Override
protected void startUp() throws Exception {
    this.segmentStoreAdapter.startUp();
    this.autoScaleMonitor = new AutoScaleMonitor(this.segmentStoreAdapter.getStreamSegmentStore(), AutoScalerConfig.builder().build());
}
Also used : AutoScaleMonitor(io.pravega.segmentstore.server.host.stat.AutoScaleMonitor)

Example 7 with AutoScaleMonitor

use of io.pravega.segmentstore.server.host.stat.AutoScaleMonitor in project pravega by pravega.

the class EndToEndAutoScaleDownTest method main.

public static void main(String[] args) throws Exception {
    try {
        @Cleanup TestingServer zkTestServer = new TestingServerStarter().start();
        int port = Config.SERVICE_PORT;
        @Cleanup ControllerWrapper controllerWrapper = new ControllerWrapper(zkTestServer.getConnectString(), port, false);
        Controller controller = controllerWrapper.getController();
        controllerWrapper.getControllerService().createScope(NameUtils.INTERNAL_SCOPE_NAME, 0L).get();
        ClientFactoryImpl internalCF = new ClientFactoryImpl(NameUtils.INTERNAL_SCOPE_NAME, controller, new SocketConnectionFactoryImpl(ClientConfig.builder().build()));
        ServiceBuilder serviceBuilder = ServiceBuilder.newInMemoryBuilder(ServiceBuilderConfig.getDefaultConfig());
        serviceBuilder.initialize();
        StreamSegmentStore store = serviceBuilder.createStreamSegmentService();
        TableStore tableStore = serviceBuilder.createTableStoreService();
        @Cleanup AutoScaleMonitor autoScaleMonitor = new AutoScaleMonitor(store, internalCF, AutoScalerConfig.builder().with(AutoScalerConfig.MUTE_IN_SECONDS, 0).with(AutoScalerConfig.COOLDOWN_IN_SECONDS, 0).with(AutoScalerConfig.CACHE_CLEANUP_IN_SECONDS, 5).with(AutoScalerConfig.CACHE_EXPIRY_IN_SECONDS, 30).build());
        @Cleanup PravegaConnectionListener server = new PravegaConnectionListener(false, false, "localhost", 12345, store, tableStore, autoScaleMonitor.getStatsRecorder(), autoScaleMonitor.getTableSegmentStatsRecorder(), null, null, null, true, serviceBuilder.getLowPriorityExecutor(), Config.TLS_PROTOCOL_VERSION.toArray(new String[Config.TLS_PROTOCOL_VERSION.size()]));
        server.startListening();
        controllerWrapper.awaitRunning();
        controllerWrapper.getControllerService().createScope("test", 0L).get();
        controller.createStream("test", "test", CONFIG).get();
        Stream stream = new StreamImpl("test", "test");
        Map<Double, Double> map = new HashMap<>();
        map.put(0.0, 0.33);
        map.put(0.33, 0.66);
        map.put(0.66, 1.0);
        @Cleanup("shutdownNow") ScheduledExecutorService executor = ExecutorServiceHelpers.newScheduledThreadPool(1, "test");
        controller.scaleStream(stream, Collections.singletonList(0L), map, executor).getFuture().get();
        Retry.withExpBackoff(10, 10, 100, 10000).retryingOn(NotDoneException.class).throwingOn(RuntimeException.class).runAsync(() -> controller.getCurrentSegments("test", "test").thenAccept(streamSegments -> {
            if (streamSegments.getSegments().size() < 3) {
                System.err.println("Success");
                log.info("Success");
                System.exit(0);
            } else {
                throw new NotDoneException();
            }
        }), executor).exceptionally(e -> {
            System.err.println("Failure");
            log.error("Failure");
            System.exit(1);
            return null;
        }).get();
    } catch (Throwable e) {
        System.err.print("Test failed with exception: " + e.getMessage());
        System.exit(-1);
    }
    System.exit(0);
}
Also used : TestingServer(org.apache.curator.test.TestingServer) StreamImpl(io.pravega.client.stream.impl.StreamImpl) Retry(io.pravega.common.util.Retry) TableStore(io.pravega.segmentstore.contracts.tables.TableStore) AutoScaleMonitor(io.pravega.segmentstore.server.host.stat.AutoScaleMonitor) Cleanup(lombok.Cleanup) HashMap(java.util.HashMap) StreamConfiguration(io.pravega.client.stream.StreamConfiguration) ServiceBuilderConfig(io.pravega.segmentstore.server.store.ServiceBuilderConfig) ServiceBuilder(io.pravega.segmentstore.server.store.ServiceBuilder) ClientFactoryImpl(io.pravega.client.stream.impl.ClientFactoryImpl) TestingServerStarter(io.pravega.test.common.TestingServerStarter) Stream(io.pravega.client.stream.Stream) Map(java.util.Map) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) TestingServer(org.apache.curator.test.TestingServer) PravegaConnectionListener(io.pravega.segmentstore.server.host.handler.PravegaConnectionListener) SocketConnectionFactoryImpl(io.pravega.client.connection.impl.SocketConnectionFactoryImpl) StreamSegmentStore(io.pravega.segmentstore.contracts.StreamSegmentStore) AutoScalerConfig(io.pravega.segmentstore.server.host.stat.AutoScalerConfig) NameUtils(io.pravega.shared.NameUtils) Slf4j(lombok.extern.slf4j.Slf4j) Config(io.pravega.controller.util.Config) ExecutorServiceHelpers(io.pravega.common.concurrent.ExecutorServiceHelpers) Collections(java.util.Collections) ScalingPolicy(io.pravega.client.stream.ScalingPolicy) Controller(io.pravega.client.control.impl.Controller) ClientConfig(io.pravega.client.ClientConfig) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) AutoScaleMonitor(io.pravega.segmentstore.server.host.stat.AutoScaleMonitor) TestingServerStarter(io.pravega.test.common.TestingServerStarter) HashMap(java.util.HashMap) Controller(io.pravega.client.control.impl.Controller) SocketConnectionFactoryImpl(io.pravega.client.connection.impl.SocketConnectionFactoryImpl) Cleanup(lombok.Cleanup) PravegaConnectionListener(io.pravega.segmentstore.server.host.handler.PravegaConnectionListener) ServiceBuilder(io.pravega.segmentstore.server.store.ServiceBuilder) TableStore(io.pravega.segmentstore.contracts.tables.TableStore) StreamSegmentStore(io.pravega.segmentstore.contracts.StreamSegmentStore) ClientFactoryImpl(io.pravega.client.stream.impl.ClientFactoryImpl) StreamImpl(io.pravega.client.stream.impl.StreamImpl) Stream(io.pravega.client.stream.Stream)

Example 8 with AutoScaleMonitor

use of io.pravega.segmentstore.server.host.stat.AutoScaleMonitor in project pravega by pravega.

the class MetricsTest method setup.

@Before
public void setup() throws Exception {
    final int controllerPort = TestUtils.getAvailableListenPort();
    final String serviceHost = "localhost";
    final int servicePort = TestUtils.getAvailableListenPort();
    final int containerCount = 4;
    // 1. Start Metrics service
    log.info("Initializing metrics provider ...");
    MetricsConfig metricsConfig = MetricsConfig.builder().with(MetricsConfig.ENABLE_STATISTICS, true).with(MetricsConfig.ENABLE_STATSD_REPORTER, false).build();
    metricsConfig.setDynamicCacheEvictionDuration(Duration.ofSeconds(2));
    MetricsProvider.initialize(metricsConfig);
    statsProvider = MetricsProvider.getMetricsProvider();
    statsProvider.startWithoutExporting();
    log.info("Metrics Stats provider is started");
    // 2. Start ZK
    this.zkTestServer = new TestingServerStarter().start();
    // 3. Start Pravega SegmentStore service.
    serviceBuilder = ServiceBuilder.newInMemoryBuilder(ServiceBuilderConfig.getDefaultConfig());
    serviceBuilder.initialize();
    StreamSegmentStore store = serviceBuilder.createStreamSegmentService();
    monitor = new AutoScaleMonitor(store, AutoScalerConfig.builder().build());
    TableStore tableStore = serviceBuilder.createTableStoreService();
    this.server = new PravegaConnectionListener(false, false, "localhost", servicePort, store, tableStore, monitor.getStatsRecorder(), monitor.getTableSegmentStatsRecorder(), new PassingTokenVerifier(), null, null, true, this.serviceBuilder.getLowPriorityExecutor(), SecurityConfigDefaults.TLS_PROTOCOL_VERSION);
    this.server.startListening();
    // 4. Start Pravega Controller service
    this.controllerWrapper = new ControllerWrapper(zkTestServer.getConnectString(), false, controllerPort, serviceHost, servicePort, containerCount);
    this.controllerWrapper.awaitRunning();
    this.controller = controllerWrapper.getController();
}
Also used : StreamSegmentStore(io.pravega.segmentstore.contracts.StreamSegmentStore) AutoScaleMonitor(io.pravega.segmentstore.server.host.stat.AutoScaleMonitor) TestingServerStarter(io.pravega.test.common.TestingServerStarter) PassingTokenVerifier(io.pravega.segmentstore.server.host.delegationtoken.PassingTokenVerifier) PravegaConnectionListener(io.pravega.segmentstore.server.host.handler.PravegaConnectionListener) MetricsConfig(io.pravega.shared.metrics.MetricsConfig) ControllerWrapper(io.pravega.test.integration.demo.ControllerWrapper) TableStore(io.pravega.segmentstore.contracts.tables.TableStore) Before(org.junit.Before)

Example 9 with AutoScaleMonitor

use of io.pravega.segmentstore.server.host.stat.AutoScaleMonitor in project pravega by pravega.

the class StreamMetricsTest method setup.

@Before
public void setup() throws Exception {
    controllerPort = TestUtils.getAvailableListenPort();
    final String serviceHost = "localhost";
    final int servicePort = TestUtils.getAvailableListenPort();
    final int containerCount = 4;
    // 1. Start Metrics service
    log.info("Initializing metrics provider ...");
    MetricsConfig metricsConfig = MetricsConfig.builder().with(MetricsConfig.ENABLE_STATISTICS, true).with(MetricsConfig.ENABLE_STATSD_REPORTER, false).build();
    metricsConfig.setDynamicCacheEvictionDuration(Duration.ofSeconds(60));
    MetricsProvider.initialize(metricsConfig);
    statsProvider = MetricsProvider.getMetricsProvider();
    statsProvider.startWithoutExporting();
    log.info("Metrics Stats provider is started");
    // 2. Start ZK
    this.zkTestServer = new TestingServerStarter().start();
    // 3. Start Pravega SegmentStore service.
    serviceBuilder = ServiceBuilder.newInMemoryBuilder(ServiceBuilderConfig.getDefaultConfig());
    serviceBuilder.initialize();
    StreamSegmentStore store = serviceBuilder.createStreamSegmentService();
    monitor = new AutoScaleMonitor(store, AutoScalerConfig.builder().build());
    TableStore tableStore = serviceBuilder.createTableStoreService();
    this.server = new PravegaConnectionListener(false, false, "localhost", servicePort, store, tableStore, monitor.getStatsRecorder(), monitor.getTableSegmentStatsRecorder(), new PassingTokenVerifier(), null, null, true, this.serviceBuilder.getLowPriorityExecutor(), SecurityConfigDefaults.TLS_PROTOCOL_VERSION);
    this.server.startListening();
    // 4. Start Pravega Controller service
    this.controllerWrapper = new ControllerWrapper(zkTestServer.getConnectString(), false, controllerPort, serviceHost, servicePort, containerCount);
    this.controllerWrapper.awaitRunning();
    this.controller = controllerWrapper.getController();
}
Also used : StreamSegmentStore(io.pravega.segmentstore.contracts.StreamSegmentStore) AutoScaleMonitor(io.pravega.segmentstore.server.host.stat.AutoScaleMonitor) TestingServerStarter(io.pravega.test.common.TestingServerStarter) PassingTokenVerifier(io.pravega.segmentstore.server.host.delegationtoken.PassingTokenVerifier) PravegaConnectionListener(io.pravega.segmentstore.server.host.handler.PravegaConnectionListener) MetricsConfig(io.pravega.shared.metrics.MetricsConfig) ControllerWrapper(io.pravega.test.integration.demo.ControllerWrapper) TableStore(io.pravega.segmentstore.contracts.tables.TableStore) Before(org.junit.Before)

Aggregations

AutoScaleMonitor (io.pravega.segmentstore.server.host.stat.AutoScaleMonitor)9 PravegaConnectionListener (io.pravega.segmentstore.server.host.handler.PravegaConnectionListener)8 StreamSegmentStore (io.pravega.segmentstore.contracts.StreamSegmentStore)7 TableStore (io.pravega.segmentstore.contracts.tables.TableStore)7 TestingServerStarter (io.pravega.test.common.TestingServerStarter)5 SocketConnectionFactoryImpl (io.pravega.client.connection.impl.SocketConnectionFactoryImpl)4 ClientFactoryImpl (io.pravega.client.stream.impl.ClientFactoryImpl)4 AutoScalerConfig (io.pravega.segmentstore.server.host.stat.AutoScalerConfig)4 ServiceBuilder (io.pravega.segmentstore.server.store.ServiceBuilder)4 ClientConfig (io.pravega.client.ClientConfig)3 Controller (io.pravega.client.control.impl.Controller)3 ScalingPolicy (io.pravega.client.stream.ScalingPolicy)3 StreamConfiguration (io.pravega.client.stream.StreamConfiguration)3 MockClientFactory (io.pravega.client.stream.mock.MockClientFactory)3 ExecutorServiceHelpers (io.pravega.common.concurrent.ExecutorServiceHelpers)3 Retry (io.pravega.common.util.Retry)3 Config (io.pravega.controller.util.Config)3 PassingTokenVerifier (io.pravega.segmentstore.server.host.delegationtoken.PassingTokenVerifier)3 ServiceBuilderConfig (io.pravega.segmentstore.server.store.ServiceBuilderConfig)3 NameUtils (io.pravega.shared.NameUtils)3