当前位置: 首页>>代码示例>>Java>>正文


Java ServiceRegistrationHandle类代码示例

本文整理汇总了Java中com.spotify.helios.serviceregistration.ServiceRegistrationHandle的典型用法代码示例。如果您正苦于以下问题:Java ServiceRegistrationHandle类的具体用法?Java ServiceRegistrationHandle怎么用?Java ServiceRegistrationHandle使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ServiceRegistrationHandle类属于com.spotify.helios.serviceregistration包,在下文中一共展示了ServiceRegistrationHandle类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testUnRegistrationNotRefreshedAnyMore

import com.spotify.helios.serviceregistration.ServiceRegistrationHandle; //导入依赖的package包/类
@Test
public void testUnRegistrationNotRefreshedAnyMore() throws Exception {
  final SkyDnsServiceRegistrar registrar = makeRegistrar();
  when(client.set(ETCD_KEY, EXPECTED, TTL))
      .thenReturn(Futures.immediateFuture(response));

  final ServiceRegistrationHandle handle = registrar.register(
      new ServiceRegistration(ENDPOINTS));
  verify(client, timeout(WAIT_TIMEOUT)).set(ETCD_KEY, EXPECTED, TTL);

  when(client.delete(ETCD_KEY)).thenReturn(Futures.immediateFuture(response));
  registrar.unregister(handle);
  verify(client, timeout(WAIT_TIMEOUT)).delete(ETCD_KEY);

  Thread.sleep(2000);
  verify(client, VerificationModeFactory.noMoreInteractions()).set(ETCD_KEY, EXPECTED, TTL);
  registrar.close();
}
 
开发者ID:spotify,项目名称:helios-skydns,代码行数:19,代码来源:SkyDnsServiceRegistrarTest.java

示例2: register

import com.spotify.helios.serviceregistration.ServiceRegistrationHandle; //导入依赖的package包/类
@Override
public ServiceRegistrationHandle register(final ServiceRegistration registration) {
    final ServiceRegistrationHandle newHandle = new ServiceRegistrationHandle() {};
    handles.put(newHandle, registration);

    for (final ServiceRegistration.Endpoint endpoint : registration.getEndpoints()) {
        if (!endpoints.add(endpoint.getName())) {
            log.error("Endpoint names must be unique since they map to a Consul Service ID. " +
                      "'{}' already present.", endpoint.getName());
        }
    }

    try {
        sendRegistration(registration);
    } catch (Exception e) {
        log.warn("Error performing registration", e);
    }
    return newHandle;
}
 
开发者ID:SVT,项目名称:helios-consul,代码行数:20,代码来源:ConsulServiceRegistrar.java

示例3: testEndpointTags

import com.spotify.helios.serviceregistration.ServiceRegistrationHandle; //导入依赖的package包/类
@Test
public void testEndpointTags() throws Exception {
	final String serviceId = "test-service-with-tags-v2";

	// Register a service
	final ConsulServiceRegistrar registrar = newRegistrar();
	final ServiceRegistrationHandle handle = registrar.register(
		newService(serviceId, Arrays.asList("tag-1", "tag-2")));
	final ConsulClient client = registrar.getConsulClient();

	Thread.sleep(1000);

	AgentService service = client.getAgentServicesWithTag(TAG).get(serviceId);

	Set<String> expectedTags = ImmutableSet.of(TAG, "protocol-tcp", "v2", "tag-1", "tag-2");
	Set<String> actualTags = ImmutableSet.copyOf(service.getTags());

	assertEquals(expectedTags, actualTags);

	// Cleanup
	registrar.unregister(handle);
	Thread.sleep(1000);
	assertTrue(registrar.getConsulClient().getAgentServicesWithTag(TAG).isEmpty());
}
 
开发者ID:SVT,项目名称:helios-consul,代码行数:25,代码来源:ConsulClientITCase.java

示例4: register

import com.spotify.helios.serviceregistration.ServiceRegistrationHandle; //导入依赖的package包/类
@Override
public ServiceRegistrationHandle register(ServiceRegistration registration) {
  final ServiceRegistrationHandle newHandle = new ServiceRegistrationHandle(){};

  handles.put(newHandle, registration);
  try {
    sendRegistration(registration);
  } catch (Exception e) {
    log.warn("Error performing registration", e);
  }
  return newHandle;
}
 
开发者ID:spotify,项目名称:helios-skydns,代码行数:13,代码来源:SkyDnsServiceRegistrar.java

示例5: unregister

import com.spotify.helios.serviceregistration.ServiceRegistrationHandle; //导入依赖的package包/类
@Override
public void unregister(final ServiceRegistrationHandle handle) {
  if (!handles.containsKey(handle)) {
    return;
  }

  try {
    sendDeRegistration(handle);
  } catch (Exception e) {
    log.warn("error removing registration handle {}", handle, e);
  }

  handles.remove(handle);
}
 
开发者ID:spotify,项目名称:helios-skydns,代码行数:15,代码来源:SkyDnsServiceRegistrar.java

示例6: sendDeRegistration

import com.spotify.helios.serviceregistration.ServiceRegistrationHandle; //导入依赖的package包/类
private void sendDeRegistration(ServiceRegistrationHandle handle) {
  final ServiceRegistration registration = handles.get(handle);
  if (registration == null) {
    return;
  }
  for (Endpoint endpoint : registration.getEndpoints()) {
    etcdClient.delete(makeKey(endpoint));
  }
}
 
开发者ID:spotify,项目名称:helios-skydns,代码行数:10,代码来源:SkyDnsServiceRegistrar.java

示例7: testDeregistration

import com.spotify.helios.serviceregistration.ServiceRegistrationHandle; //导入依赖的package包/类
@Test
public void testDeregistration() {
  final SkyDnsServiceRegistrar registrar = makeRegistrar();
  when(client.set(ETCD_KEY, EXPECTED, TTL))
      .thenReturn(Futures.immediateFuture(response));
  final ServiceRegistrationHandle handle = registrar.register(new ServiceRegistration(ENDPOINTS));

  when(client.delete(ETCD_KEY)).thenReturn(Futures.immediateFuture(response));
  registrar.unregister(handle);
  verify(client, timeout(WAIT_TIMEOUT)).delete(ETCD_KEY);
  registrar.close();
}
 
开发者ID:spotify,项目名称:helios-skydns,代码行数:13,代码来源:SkyDnsServiceRegistrarTest.java

示例8: unregister

import com.spotify.helios.serviceregistration.ServiceRegistrationHandle; //导入依赖的package包/类
@Override
public void unregister(ServiceRegistrationHandle handle) {
    if (!handles.containsKey(handle)) {
        return;
    }
    try {
        sendDeRegistration(handle);
    } catch (Exception e) {
        log.warn("Error removing registration handle {}", handle, e);
    }
    handles.remove(handle);
}
 
开发者ID:SVT,项目名称:helios-consul,代码行数:13,代码来源:ConsulServiceRegistrar.java

示例9: sendDeRegistration

import com.spotify.helios.serviceregistration.ServiceRegistrationHandle; //导入依赖的package包/类
private void sendDeRegistration(ServiceRegistrationHandle handle) {
    final ServiceRegistration registration = handles.get(handle);
    if (registration == null) {
        return;
    }
    for (ServiceRegistration.Endpoint endpoint : registration.getEndpoints()) {
        consulClient.deregister(endpoint.getName());
        endpoints.remove(endpoint.getName());
    }
}
 
开发者ID:SVT,项目名称:helios-consul,代码行数:11,代码来源:ConsulServiceRegistrar.java

示例10: testUnregister

import com.spotify.helios.serviceregistration.ServiceRegistrationHandle; //导入依赖的package包/类
@Test
public void testUnregister() throws Exception {
    RegistrarConfig config = ConsulServiceRegistrarFactory.createConfig();
    ServiceRegistrar registrar = new ConsulServiceRegistrar(consulClient, config);
    ServiceRegistrationHandle handle = registrar.register(new ServiceRegistration(Arrays.asList(ENDPOINT_WITHOUT_TAGS)));
    registrar.unregister(handle);
    registrar.close();

    verify(consulClient).register((Service) anyObject());
    verify(consulClient).deregister(ENDPOINT_WITHOUT_TAGS.getName());
    verify(consulClient).close();
}
 
开发者ID:SVT,项目名称:helios-consul,代码行数:13,代码来源:ServiceRegistrarTest.java

示例11: testReRegister

import com.spotify.helios.serviceregistration.ServiceRegistrationHandle; //导入依赖的package包/类
@Test
public void testReRegister() throws Exception {
	final String serviceId = "test-2-service-v12";

	// Register a service
	final ConsulServiceRegistrar registrar = newRegistrar();
	final ServiceRegistrationHandle handle = registrar.register(newService(serviceId));
	final ConsulClient client = registrar.getConsulClient();

	Thread.sleep(1000);

	// Check that the service actually is registered
	assertTrue(client.getAgentServicesWithTag(TAG).containsKey(serviceId));

	// Consul "forgets" about the service (i.e. manually de-register it)
	client.deregister(serviceId).get();
	assertTrue(client.getAgentServicesWithTag(TAG).isEmpty());

	// Force re-registration
	registrar.syncState();

	// Check that the service is re-registered
	assertTrue(client.getAgentServicesWithTag(TAG).containsKey(serviceId));

	// Cleanup
	registrar.unregister(handle);
	Thread.sleep(1000);
	assertTrue(registrar.getConsulClient().getAgentServicesWithTag(TAG).isEmpty());
}
 
开发者ID:SVT,项目名称:helios-consul,代码行数:30,代码来源:ConsulClientITCase.java


注:本文中的com.spotify.helios.serviceregistration.ServiceRegistrationHandle类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。