Search in sources :

Example 1 with DynamicLongProperty

use of com.netflix.config.DynamicLongProperty in project incubator-servicecomb-java-chassis by apache.

the class DynamicPropertiesImpl method getLongProperty.

@Override
public long getLongProperty(String propertyName, LongConsumer consumer, long defaultValue) {
    DynamicLongProperty prop = propertyFactoryInstance().getLongProperty(propertyName, defaultValue);
    prop.addCallback(() -> consumer.accept(prop.get()));
    return prop.get();
}
Also used : DynamicLongProperty(com.netflix.config.DynamicLongProperty)

Example 2 with DynamicLongProperty

use of com.netflix.config.DynamicLongProperty in project incubator-servicecomb-java-chassis by apache.

the class HighwayClient method createTcpClientConfig.

private TcpClientConfig createTcpClientConfig() {
    TcpClientConfig tcpClientConfig = new TcpClientConfig();
    DynamicLongProperty prop = AbstractTransport.getRequestTimeoutProperty();
    prop.addCallback(new Runnable() {

        public void run() {
            tcpClientConfig.setRequestTimeoutMillis(prop.get());
        }
    });
    tcpClientConfig.setRequestTimeoutMillis(prop.get());
    SSLOptionFactory factory = SSLOptionFactory.createSSLOptionFactory(SSL_KEY, null);
    SSLOption sslOption;
    if (factory == null) {
        sslOption = SSLOption.buildFromYaml(SSL_KEY);
    } else {
        sslOption = factory.createSSLOption();
    }
    SSLCustom sslCustom = SSLCustom.createSSLCustom(sslOption.getSslCustomClass());
    VertxTLSBuilder.buildClientOptionsBase(sslOption, sslCustom, tcpClientConfig);
    return tcpClientConfig;
}
Also used : TcpClientConfig(org.apache.servicecomb.foundation.vertx.client.tcp.TcpClientConfig) SSLOptionFactory(org.apache.servicecomb.foundation.ssl.SSLOptionFactory) SSLOption(org.apache.servicecomb.foundation.ssl.SSLOption) SSLCustom(org.apache.servicecomb.foundation.ssl.SSLCustom) DynamicLongProperty(com.netflix.config.DynamicLongProperty)

Example 3 with DynamicLongProperty

use of com.netflix.config.DynamicLongProperty in project java-chassis by ServiceComb.

the class DynamicPropertiesImpl method getLongProperty.

@Override
public long getLongProperty(String propertyName, LongConsumer consumer, long defaultValue) {
    DynamicLongProperty prop = propertyFactoryInstance().getLongProperty(propertyName, defaultValue);
    prop.addCallback(() -> consumer.accept(prop.get()));
    return prop.get();
}
Also used : DynamicLongProperty(com.netflix.config.DynamicLongProperty)

Example 4 with DynamicLongProperty

use of com.netflix.config.DynamicLongProperty in project wildfly-swarm by wildfly-swarm.

the class SyncCircuitBreakerDisabledTest method testDefaultHystrixCircuitBreakerUsed.

@Test
public void testDefaultHystrixCircuitBreakerUsed() throws InterruptedException {
    // Verify Hystrix config first
    DynamicLongProperty intervalInMilliseconds = DynamicPropertyFactory.getInstance().getLongProperty("hystrix.command.default.metrics.healthSnapshot.intervalInMilliseconds", 500);
    assertEquals(intervalInMilliseconds.get(), 10);
    // CLOSED
    for (int i = 0; i < ShakyServiceClient.REQUEST_THRESHOLD; i++) {
        assertInvocation(false);
    }
    // Should be OPEN now
    HystrixCircuitBreaker breaker = HystrixCircuitBreaker.Factory.getInstance(HystrixCommandKey.Factory.asKey(getCommandKey()));
    assertNotNull(breaker);
    assertFalse(breaker.getClass().getName().contains("org.wildfly.swarm.microprofile.faulttolerance"));
    assertTrue(breaker.isOpen());
    assertInvocation(true);
    TimeUnit.MILLISECONDS.sleep(ShakyServiceClient.DELAY);
    // Should be HALF-OPEN
    assertInvocation(false);
    // OPEN again
    assertInvocation(true);
}
Also used : HystrixCircuitBreaker(com.netflix.hystrix.HystrixCircuitBreaker) DynamicLongProperty(com.netflix.config.DynamicLongProperty) Test(org.junit.Test)

Example 5 with DynamicLongProperty

use of com.netflix.config.DynamicLongProperty in project chassis by Kixeye.

the class ChassisConfigPropertiesTest method testBasicProperty.

@Test
public void testBasicProperty() {
    DynamicLongProperty dynamicLongProperty = DynamicPropertyFactory.getInstance().getLongProperty("com.kixeye.platform.chassis.testLong", -1);
    assertEquals(42, dynamicLongProperty.get());
}
Also used : DynamicLongProperty(com.netflix.config.DynamicLongProperty) Test(org.junit.Test)

Aggregations

DynamicLongProperty (com.netflix.config.DynamicLongProperty)5 Test (org.junit.Test)2 HystrixCircuitBreaker (com.netflix.hystrix.HystrixCircuitBreaker)1 SSLCustom (org.apache.servicecomb.foundation.ssl.SSLCustom)1 SSLOption (org.apache.servicecomb.foundation.ssl.SSLOption)1 SSLOptionFactory (org.apache.servicecomb.foundation.ssl.SSLOptionFactory)1 TcpClientConfig (org.apache.servicecomb.foundation.vertx.client.tcp.TcpClientConfig)1