com.alibaba.csp.sentinel.config.SentinelConfig Java Examples

The following examples show how to use com.alibaba.csp.sentinel.config.SentinelConfig. 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: DubboUtilsTest.java    From Sentinel with Apache License 2.0 6 votes vote down vote up
@Test
public void testGetResourceNameWithPrefix() throws NoSuchMethodException {
    Invoker invoker = mock(Invoker.class);
    when(invoker.getInterface()).thenReturn(DemoService.class);

    Invocation invocation = mock(Invocation.class);
    Method method = DemoService.class.getDeclaredMethod("sayHello", String.class, int.class);
    when(invocation.getMethodName()).thenReturn(method.getName());
    when(invocation.getParameterTypes()).thenReturn(method.getParameterTypes());

    //test with default prefix
    String resourceName = DubboUtils.getResourceName(invoker, invocation, DubboConfig.getDubboProviderPrefix());
    assertEquals("dubbo:provider:com.alibaba.csp.sentinel.adapter.dubbo.provider.DemoService:sayHello(java.lang.String,int)", resourceName);
    resourceName = DubboUtils.getResourceName(invoker, invocation, DubboConfig.getDubboConsumerPrefix());
    assertEquals("dubbo:consumer:com.alibaba.csp.sentinel.adapter.dubbo.provider.DemoService:sayHello(java.lang.String,int)", resourceName);


    //test with custom prefix
    SentinelConfig.setConfig(DubboConfig.DUBBO_PROVIDER_PREFIX, "my:dubbo:provider:");
    SentinelConfig.setConfig(DubboConfig.DUBBO_CONSUMER_PREFIX, "my:dubbo:consumer:");
    resourceName = DubboUtils.getResourceName(invoker, invocation, DubboConfig.getDubboProviderPrefix());
    assertEquals("my:dubbo:provider:com.alibaba.csp.sentinel.adapter.dubbo.provider.DemoService:sayHello(java.lang.String,int)", resourceName);
    resourceName = DubboUtils.getResourceName(invoker, invocation, DubboConfig.getDubboConsumerPrefix());
    assertEquals("my:dubbo:consumer:com.alibaba.csp.sentinel.adapter.dubbo.provider.DemoService:sayHello(java.lang.String,int)", resourceName);

}
 
Example #2
Source File: HttpEventTask.java    From Sentinel with Apache License 2.0 6 votes vote down vote up
private static String readLine(InputStream in) throws IOException {
    ByteArrayOutputStream bos = new ByteArrayOutputStream(64);
    int data;
    while (true) {
        data = in.read();
        if (data < 0) {
            break;
        }
        if (data == '\n') {
            break;
        }
        bos.write(data);
    }
    byte[] arr = bos.toByteArray();
    if (arr.length > 0 && arr[arr.length - 1] == '\r') {
        return new String(arr, 0, arr.length - 1, SentinelConfig.charset());
    }
    return new String(arr, SentinelConfig.charset());
}
 
Example #3
Source File: SentinelEnvoyRlsServer.java    From Sentinel with Apache License 2.0 6 votes vote down vote up
private static int resolvePort() {
    final int defaultPort = SentinelEnvoyRlsConstants.DEFAULT_GRPC_PORT;
    // Order: system env > property
    String portStr = Optional.ofNullable(System.getenv(SentinelEnvoyRlsConstants.GRPC_PORT_ENV_KEY))
        .orElse(SentinelConfig.getConfig(SentinelEnvoyRlsConstants.GRPC_PORT_PROPERTY_KEY));
    if (StringUtil.isBlank(portStr)) {
        return defaultPort;
    }
    try {
        int port = Integer.parseInt(portStr);
        if (port <= 0 || port > 65535) {
            RecordLog.warn("[SentinelEnvoyRlsServer] Invalid port <" + portStr + ">, using default" + defaultPort);
            return defaultPort;
        }
        return port;
    } catch (Exception ex) {
        RecordLog.warn("[SentinelEnvoyRlsServer] Failed to resolve port, using default " + defaultPort);
        System.err.println("[SentinelEnvoyRlsServer] Failed to resolve port, using default " + defaultPort);
        return defaultPort;
    }
}
 
Example #4
Source File: EtcdDataSourceDemo.java    From Sentinel with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) {

        String rule_key = "sentinel_demo_rule_key";
        String yourUserName = "root";
        String yourPassWord = "12345";
        String endPoints = "http://127.0.0.1:2379";
        SentinelConfig.setConfig(EtcdConfig.END_POINTS, endPoints);
        SentinelConfig.setConfig(EtcdConfig.USER, yourUserName);
        SentinelConfig.setConfig(EtcdConfig.PASSWORD, yourPassWord);
        SentinelConfig.setConfig(EtcdConfig.CHARSET, "utf-8");
        SentinelConfig.setConfig(EtcdConfig.AUTH_ENABLE, "true");

        ReadableDataSource<String, List<FlowRule>> flowRuleEtcdDataSource = new EtcdDataSource<>(rule_key, (rule) -> JSON.parseArray(rule, FlowRule.class));
        FlowRuleManager.register2Property(flowRuleEtcdDataSource.getProperty());
        List<FlowRule> rules = FlowRuleManager.getRules();
        System.out.println(rules);
    }
 
Example #5
Source File: WebServletConfig.java    From Sentinel with Apache License 2.0 6 votes vote down vote up
/**
 * <p>Get the HTTP status when using the default block page.</p>
 * <p>You can set the status code with the {@code -Dcsp.sentinel.web.servlet.block.status}
 * property. When the property is empty or invalid, Sentinel will use 429 (Too Many Requests)
 * as the default status code.</p>
 *
 * @return the HTTP status of the default block page
 * @since 1.7.0
 */
public static int getBlockPageHttpStatus() {
    String value = SentinelConfig.getConfig(BLOCK_PAGE_HTTP_STATUS_CONF_KEY);
    if (StringUtil.isEmpty(value)) {
        return HTTP_STATUS_TOO_MANY_REQUESTS;
    }
    try {
        int s = Integer.parseInt(value);
        if (s <= 0) {
            throw new IllegalArgumentException("Invalid status code: " + s);
        }
        return s;
    } catch (Exception e) {
        RecordLog.warn("[WebServletConfig] Invalid block HTTP status (" + value + "), using default 429");
        setBlockPageHttpStatus(HTTP_STATUS_TOO_MANY_REQUESTS);
    }
    return HTTP_STATUS_TOO_MANY_REQUESTS;
}
 
Example #6
Source File: HeartbeatSenderInitFuncTest.java    From Sentinel with Apache License 2.0 6 votes vote down vote up
@Test
public void testRetrieveInterval() {
    HeartbeatSender sender = mock(HeartbeatSender.class);

    long senderInterval = 5666;
    long configInterval = 6777;

    when(sender.intervalMs()).thenReturn(senderInterval);

    HeartbeatSenderInitFunc func = new HeartbeatSenderInitFunc();
    assertEquals(senderInterval, func.retrieveInterval(sender));

    // Invalid interval.
    SentinelConfig.setConfig(TransportConfig.HEARTBEAT_INTERVAL_MS, "-1");
    assertEquals(senderInterval, func.retrieveInterval(sender));

    SentinelConfig.setConfig(TransportConfig.HEARTBEAT_INTERVAL_MS, String.valueOf(configInterval));
    assertEquals(configInterval, func.retrieveInterval(sender));
}
 
Example #7
Source File: HeartbeatSenderInitFuncTest.java    From Sentinel-Dashboard-Nacos with Apache License 2.0 6 votes vote down vote up
@Test
public void testRetrieveInterval() {
    HeartbeatSender sender = mock(HeartbeatSender.class);

    long senderInterval = 5666;
    long configInterval = 6777;

    when(sender.intervalMs()).thenReturn(senderInterval);

    HeartbeatSenderInitFunc func = new HeartbeatSenderInitFunc();
    assertEquals(senderInterval, func.retrieveInterval(sender));

    // Invalid interval.
    SentinelConfig.setConfig(TransportConfig.HEARTBEAT_INTERVAL_MS, "-1");
    assertEquals(senderInterval, func.retrieveInterval(sender));

    SentinelConfig.setConfig(TransportConfig.HEARTBEAT_INTERVAL_MS, String.valueOf(configInterval));
    assertEquals(configInterval, func.retrieveInterval(sender));
}
 
Example #8
Source File: DegradeRuleManager.java    From Sentinel with Apache License 2.0 6 votes vote down vote up
public static boolean isValidRule(DegradeRule rule) {
    boolean baseValid = rule != null && !StringUtil.isBlank(rule.getResource())
        && rule.getCount() >= 0 && rule.getTimeWindow() > 0;
    if (!baseValid) {
        return false;
    }
    int maxAllowedRt = SentinelConfig.statisticMaxRt();
    if (rule.getGrade() == RuleConstant.DEGRADE_GRADE_RT) {
        if (rule.getRtSlowRequestAmount() <= 0) {
            return false;
        }
        // Warn for RT mode that exceeds the {@code TIME_DROP_VALVE}.
        if (rule.getCount() > maxAllowedRt) {
            RecordLog.warn(String.format("[DegradeRuleManager] WARN: setting large RT threshold (%.1f ms)"
                    + " in RT mode will not take effect since it exceeds the max allowed value (%d ms)",
                rule.getCount(), maxAllowedRt));
        }
    }

    // Check exception ratio mode.
    if (rule.getGrade() == RuleConstant.DEGRADE_GRADE_EXCEPTION_RATIO) {
        return rule.getCount() <= 1 && rule.getMinRequestAmount() > 0;
    }
    return true;
}
 
Example #9
Source File: HttpHeartbeatSender.java    From Sentinel-Dashboard-Nacos with Apache License 2.0 6 votes vote down vote up
@Override
public boolean sendHeartbeat() throws Exception {
    if (StringUtil.isEmpty(consoleHost)) {
        return false;
    }
    URIBuilder uriBuilder = new URIBuilder();
    uriBuilder.setScheme("http").setHost(consoleHost).setPort(consolePort)
        .setPath("/registry/machine")
        .setParameter("app", AppNameUtil.getAppName())
        .setParameter("app_type", String.valueOf(SentinelConfig.getAppType()))
        .setParameter("v", Constants.SENTINEL_VERSION)
        .setParameter("version", String.valueOf(System.currentTimeMillis()))
        .setParameter("hostname", HostNameUtil.getHostName())
        .setParameter("ip", TransportConfig.getHeartbeatClientIp())
        .setParameter("port", TransportConfig.getPort())
        .setParameter("pid", String.valueOf(PidUtil.getPid()));

    HttpGet request = new HttpGet(uriBuilder.build());
    request.setConfig(requestConfig);
    // Send heartbeat request.
    CloseableHttpResponse response = client.execute(request);
    response.close();
    return true;
}
 
Example #10
Source File: DubboUtilsTest.java    From Sentinel with Apache License 2.0 6 votes vote down vote up
@Test
public void testGetInterfaceName() {

    URL url = URL.valueOf("dubbo://127.0.0.1:2181")
            .addParameter(CommonConstants.VERSION_KEY, "1.0.0")
            .addParameter(CommonConstants.GROUP_KEY, "grp1")
            .addParameter(CommonConstants.INTERFACE_KEY, DemoService.class.getName());
    Invoker invoker = mock(Invoker.class);
    when(invoker.getUrl()).thenReturn(url);
    when(invoker.getInterface()).thenReturn(DemoService.class);

    SentinelConfig.setConfig(DUBBO_INTERFACE_GROUP_VERSION_ENABLED, "false");
    assertEquals("com.alibaba.csp.sentinel.adapter.dubbo.provider.DemoService", DubboUtils.getInterfaceName(invoker));

    SentinelConfig.setConfig(DUBBO_INTERFACE_GROUP_VERSION_ENABLED, "true");
    assertEquals("com.alibaba.csp.sentinel.adapter.dubbo.provider.DemoService:1.0.0:grp1", DubboUtils.getInterfaceName(invoker));

}
 
Example #11
Source File: HttpEventTask.java    From Sentinel with Apache License 2.0 6 votes vote down vote up
protected static void parseSingleParam(String single, CommandRequest request) {
    if (single == null || single.length() < 3) {
        return;
    }

    int index = single.indexOf('=');
    if (index <= 0 || index >= single.length() - 1) {
        // empty key/val or nothing found
        return;
    }

    String value = StringUtil.trim(single.substring(index + 1));
    String key = StringUtil.trim(single.substring(0, index));
    try {
        key = URLDecoder.decode(key, SentinelConfig.charset());
        value = URLDecoder.decode(value, SentinelConfig.charset());
    } catch (UnsupportedEncodingException e) {
    }

    request.addParam(key, value);
}
 
Example #12
Source File: HttpEventTask.java    From Sentinel-Dashboard-Nacos with Apache License 2.0 6 votes vote down vote up
private void parseParams(String queryString, CommandRequest request) {
    for (String parameter : queryString.split("&")) {
        if (StringUtil.isBlank(parameter)) {
            continue;
        }

        String[] keyValue = parameter.split("=");
        if (keyValue.length != 2) {
            continue;
        }

        String value = StringUtil.trim(keyValue[1]);
        try {
            value = URLDecoder.decode(value, SentinelConfig.charset());
        } catch (UnsupportedEncodingException e) {
        }

        request.addParam(StringUtil.trim(keyValue[0]), value);
    }
}
 
Example #13
Source File: HttpEventTask.java    From Sentinel-Dashboard-Nacos with Apache License 2.0 6 votes vote down vote up
private void handleResponse(CommandResponse response, /*@NonNull*/ final PrintWriter printWriter,
    /*@NonNull*/ final OutputStream rawOutputStream) throws Exception {
    if (response.isSuccess()) {
        if (response.getResult() == null) {
            writeOkStatusLine(printWriter);
            return;
        }
        // Write 200 OK status line.
        writeOkStatusLine(printWriter);
        // Here we directly use `toString` to encode the result to plain text.
        byte[] buffer = response.getResult().toString().getBytes(SentinelConfig.charset());
        rawOutputStream.write(buffer);
        rawOutputStream.flush();
    } else {
        String msg = SERVER_ERROR_MESSAGE;
        if (response.getException() != null) {
            msg = response.getException().getMessage();
        }
        badRequest(printWriter, msg);
    }
}
 
Example #14
Source File: BaseTest.java    From Sentinel with Apache License 2.0 5 votes vote down vote up
private void clearDubboContext() {
    SentinelConfig.setConfig("csp.sentinel.dubbo.resource.use.prefix", "false");
    SentinelConfig.setConfig(DubboConfig.DUBBO_PROVIDER_PREFIX, "");
    SentinelConfig.setConfig(DubboConfig.DUBBO_CONSUMER_PREFIX, "");
    SentinelConfig.setConfig(DubboConfig.DUBBO_INTERFACE_GROUP_VERSION_ENABLED, "false");
    DubboFallbackRegistry.setConsumerFallback(new DefaultDubboFallback());
    RpcContext.removeContext();

}
 
Example #15
Source File: TransportConfigTest.java    From Sentinel with Apache License 2.0 5 votes vote down vote up
@Test
public void testGetHeartbeatClientIp() {
    String clientIp = "10.10.10.10";
    SentinelConfig.setConfig(TransportConfig.HEARTBEAT_CLIENT_IP, clientIp);
    // Set heartbeat client ip to system property.
    String ip = TransportConfig.getHeartbeatClientIp();

    assertNotNull(ip);
    assertEquals(clientIp, ip);

    // Set no heartbeat client ip.
    SentinelConfig.setConfig(TransportConfig.HEARTBEAT_CLIENT_IP, "");
    assertTrue(StringUtil.isNotEmpty(TransportConfig.getHeartbeatClientIp()));
}
 
Example #16
Source File: TransportConfigTest.java    From Sentinel with Apache License 2.0 5 votes vote down vote up
@Test
public void testGetHeartbeatInterval() {
    long interval = 20000;
    assertNull(TransportConfig.getHeartbeatIntervalMs());
    // Set valid interval.
    SentinelConfig.setConfig(TransportConfig.HEARTBEAT_INTERVAL_MS, String.valueOf(interval));
    assertEquals(new Long(interval), TransportConfig.getHeartbeatIntervalMs());
    // Set invalid interval.
    SentinelConfig.setConfig(TransportConfig.HEARTBEAT_INTERVAL_MS, "Sentinel");
    assertNull(TransportConfig.getHeartbeatIntervalMs());
}
 
Example #17
Source File: HeartbeatMessage.java    From Sentinel-Dashboard-Nacos with Apache License 2.0 5 votes vote down vote up
public HeartbeatMessage() {
    message.put("hostname", HostNameUtil.getHostName());
    message.put("ip", TransportConfig.getHeartbeatClientIp());
    message.put("app", AppNameUtil.getAppName());
    // Put application type (since 1.6.0).
    message.put("app_type", String.valueOf(SentinelConfig.getAppType()));
    message.put("port", String.valueOf(TransportConfig.getPort()));
}
 
Example #18
Source File: TransportConfig.java    From Sentinel with Apache License 2.0 5 votes vote down vote up
/**
 * Get the heartbeat api path. If the machine registry path of the dashboard
 * is modified, then the API path should also be consistent with the API path of the dashboard.
 *
 * @return the heartbeat api path
 * @since 1.7.1
 */
public static String getHeartbeatApiPath() {
    String apiPath = SentinelConfig.getConfig(HEARTBEAT_API_PATH);
    if (StringUtil.isBlank(apiPath)) {
        return HEARTBEAT_DEFAULT_PATH;
    }
    if (!apiPath.startsWith("/")) {
        apiPath = "/" + apiPath;
    }
    return apiPath;
}
 
Example #19
Source File: TransportConfig.java    From Sentinel with Apache License 2.0 5 votes vote down vote up
/**
 * Get heartbeat client local ip.
 * If the client ip not configured,it will be the address of local host
 *
 * @return the local ip.
 */
public static String getHeartbeatClientIp() {
    String ip = SentinelConfig.getConfig(HEARTBEAT_CLIENT_IP);
    if (StringUtil.isBlank(ip)) {
        ip = HostNameUtil.getIp();
    }
    return ip;
}
 
Example #20
Source File: TransportConfig.java    From Sentinel with Apache License 2.0 5 votes vote down vote up
/**
 * Get Server port of this HTTP server.
 *
 * @return the port, maybe null if not configured.
 */
public static String getPort() {
    if (runtimePort > 0) {
        return String.valueOf(runtimePort);
    }
    return SentinelConfig.getConfig(SERVER_PORT);
}
 
Example #21
Source File: ArrayMetric.java    From Sentinel with Apache License 2.0 5 votes vote down vote up
@Override
public long minRt() {
    data.currentWindow();
    long rt = SentinelConfig.statisticMaxRt();
    List<MetricBucket> list = data.values();
    for (MetricBucket window : list) {
        if (window.minRt() < rt) {
            rt = window.minRt();
        }
    }

    return Math.max(1, rt);
}
 
Example #22
Source File: HeartbeatMessage.java    From Sentinel with Apache License 2.0 5 votes vote down vote up
public HeartbeatMessage() {
    message.put("hostname", HostNameUtil.getHostName());
    message.put("ip", TransportConfig.getHeartbeatClientIp());
    message.put("app", AppNameUtil.getAppName());
    // Put application type (since 1.6.0).
    message.put("app_type", String.valueOf(SentinelConfig.getAppType()));
    message.put("port", String.valueOf(TransportConfig.getPort()));
}
 
Example #23
Source File: SentinelHealthIndicatorTests.java    From spring-cloud-alibaba with Apache License 2.0 5 votes vote down vote up
@Test
public void testSentinelDashboardConfiguredSuccess() throws Exception {
	when(sentinelProperties.isEnabled()).thenReturn(true);
	SentinelConfig.setConfig(TransportConfig.CONSOLE_SERVER, "localhost:8080");
	when(heartbeatSender.sendHeartbeat()).thenReturn(true);

	Health health = sentinelHealthIndicator.health();

	assertThat(health.getStatus()).isEqualTo(Status.UP);
}
 
Example #24
Source File: HttpHeartbeatSender.java    From Sentinel with Apache License 2.0 5 votes vote down vote up
@Override
public boolean sendHeartbeat() throws Exception {
    if (StringUtil.isEmpty(consoleHost)) {
        return false;
    }
    URIBuilder uriBuilder = new URIBuilder();
    uriBuilder.setScheme("http").setHost(consoleHost).setPort(consolePort)
        .setPath(TransportConfig.getHeartbeatApiPath())
        .setParameter("app", AppNameUtil.getAppName())
        .setParameter("app_type", String.valueOf(SentinelConfig.getAppType()))
        .setParameter("v", Constants.SENTINEL_VERSION)
        .setParameter("version", String.valueOf(System.currentTimeMillis()))
        .setParameter("hostname", HostNameUtil.getHostName())
        .setParameter("ip", TransportConfig.getHeartbeatClientIp())
        .setParameter("port", TransportConfig.getPort())
        .setParameter("pid", String.valueOf(PidUtil.getPid()));

    HttpGet request = new HttpGet(uriBuilder.build());
    request.setConfig(requestConfig);
    // Send heartbeat request.
    CloseableHttpResponse response = client.execute(request);
    response.close();
    int statusCode = response.getStatusLine().getStatusCode();
    if (statusCode == OK_STATUS) {
        return true;
    } else if (clientErrorCode(statusCode) || serverErrorCode(statusCode)) {
        RecordLog.warn("[HttpHeartbeatSender] Failed to send heartbeat to "
            + consoleHost + ":" + consolePort + ", http status code: " + statusCode);
    }

    return false;
}
 
Example #25
Source File: HttpServerHandler.java    From Sentinel with Apache License 2.0 5 votes vote down vote up
private void writeErrorResponse(int statusCode, String message, ChannelHandlerContext ctx) {
    FullHttpResponse httpResponse = new DefaultFullHttpResponse(HttpVersion.HTTP_1_1,
        HttpResponseStatus.valueOf(statusCode),
        Unpooled.copiedBuffer(message, Charset.forName(SentinelConfig.charset())));

    httpResponse.headers().set("Content-Type", "text/plain; charset=" + SentinelConfig.charset());
    ctx.write(httpResponse);

    ctx.writeAndFlush(Unpooled.EMPTY_BUFFER).addListener(ChannelFutureListener.CLOSE);
}
 
Example #26
Source File: DubboConfig.java    From Sentinel with Apache License 2.0 5 votes vote down vote up
public static Boolean getDubboBizExceptionTraceEnabled() {
    String traceBizExceptionEnabled = SentinelConfig.getConfig(TRACE_BIZ_EXCEPTION_ENABLED);
    if (StringUtil.isNotBlank(traceBizExceptionEnabled)) {
        return TRUE_STR.equalsIgnoreCase(traceBizExceptionEnabled);
    }
    return true;
}
 
Example #27
Source File: SentinelZuulAutoConfiguration.java    From spring-cloud-alibaba with Apache License 2.0 5 votes vote down vote up
@PostConstruct
private void init() {
	requestOriginParserOptional
			.ifPresent(ZuulGatewayCallbackManager::setOriginParser);
	System.setProperty(SentinelConfig.APP_TYPE,
			String.valueOf(ConfigConstants.APP_TYPE_ZUUL_GATEWAY));
}
 
Example #28
Source File: DubboConfig.java    From Sentinel with Apache License 2.0 5 votes vote down vote up
public static String getDubboConsumerPrefix() {
    if (isUsePrefix()) {
        String config = SentinelConfig.getConfig(DUBBO_CONSUMER_PREFIX);
        return StringUtil.isNotBlank(config) ? config : DEFAULT_DUBBO_CONSUMER_PREFIX;
    }
    return null;
}
 
Example #29
Source File: ClusterClientStartUpConfig.java    From Sentinel with Apache License 2.0 5 votes vote down vote up
/**
 * Get the max bytes params can be serialized
 *
 * @return the max bytes, may be null
 */
public static Integer getMaxParamByteSize() {
    String maxParamByteSize = SentinelConfig.getConfig(MAX_PARAM_BYTE_SIZE);
    try {
        return maxParamByteSize == null ? null : Integer.valueOf(maxParamByteSize);
    } catch (Exception ex) {
        RecordLog.warn("[ClusterClientStartUpConfig] Failed to parse maxParamByteSize: " + maxParamByteSize);
        return null;
    }
}
 
Example #30
Source File: SentinelHealthIndicatorTests.java    From spring-cloud-alibaba with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() {
	beanFactory = mock(DefaultListableBeanFactory.class);
	sentinelProperties = mock(SentinelProperties.class);
	sentinelHealthIndicator = new SentinelHealthIndicator(beanFactory,
			sentinelProperties);

	SentinelConfig.setConfig(TransportConfig.CONSOLE_SERVER, "");

	heartbeatSender = mock(HeartbeatSender.class);
	Field heartbeatSenderField = ReflectionUtils
			.findField(HeartbeatSenderProvider.class, "heartbeatSender");
	heartbeatSenderField.setAccessible(true);
	ReflectionUtils.setField(heartbeatSenderField, null, heartbeatSender);
}