• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java QueryParams类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: lookupRouterMessage

import com.ecwid.consul.v1.QueryParams; //导入依赖的package包/类
public ConsulRouterResp lookupRouterMessage(String serviceName, long lastConsulIndex) {
    QueryParams queryParams = new QueryParams(ConsulConstants.CONSUL_BLOCK_TIME_SECONDS, lastConsulIndex);
    Response<GetValue> orgResponse = client.getKVValue(serviceName, queryParams);
    GetValue getValue = orgResponse.getValue();
    if (getValue != null && StringUtils.isNoneBlank(getValue.getValue())) {
        String router = new String(Base64.decodeBase64(getValue.getValue()));
        ConsulRouterResp response = ConsulRouterResp.newResponse()//
                                                    .withValue(router)//
                                                    .withConsulIndex(orgResponse.getConsulIndex())//
                                                    .withConsulLastContact(orgResponse.getConsulLastContact())//
                                                    .withConsulKnowLeader(orgResponse.isConsulKnownLeader())//
                                                    .build();
        return response;
    }
    return null;
}
 
开发者ID:venus-boot,项目名称:saluki,代码行数:17,代码来源:ConsulClient.java


示例2: run

import com.ecwid.consul.v1.QueryParams; //导入依赖的package包/类
@Override
public void run() {
    Set<String> sessionIds = Sets.newHashSet();
    for (ConsulSession session : sessions) {
        try {
            String sessionId = session.getSessionId();
            if (!sessionIds.contains(sessionId)) {
                client.renewSession(sessionId, QueryParams.DEFAULT);
                sessionIds.add(sessionId);
            }
            log.debug("Sending consul heartbeat for: " + sessionId);
        } catch (Throwable e) {
            failedsessions.addAll(sessions);
            sessions.clear();
            log.error(e.getMessage(), e);
        }
    }
}
 
开发者ID:venus-boot,项目名称:saluki,代码行数:19,代码来源:TtlScheduler.java


示例3: testEmptyResolution

import com.ecwid.consul.v1.QueryParams; //导入依赖的package包/类
@Test
public void testEmptyResolution() throws Exception {
    final Response<List<CatalogService>> response = composeResponse(new ArrayList<>());

    new Expectations() {{
        catalogClient.getCatalogService(SERVICE_NAME, QueryParams.DEFAULT);
        result = response;
        times = 1;
    }};

    final List<NameResolverEvent<?>> events = runTest(resolver, 1);
    assertEquals(1, events.size());

    final NameResolverEvent e  = events.get(0);
    assertEquals(NameResolverEventType.ON_ADDRESSES, e.type);
    assertTrue(((List) e.payload).isEmpty());
}
 
开发者ID:indeedeng-alpha,项目名称:indeed-grpc-java,代码行数:18,代码来源:ConsulNameResolverTest.java


示例4: testFailingResolution

import com.ecwid.consul.v1.QueryParams; //导入依赖的package包/类
@Test
public void testFailingResolution() throws Exception {
    new Expectations() {{
        catalogClient.getCatalogService(SERVICE_NAME, QueryParams.DEFAULT);
        result = new RuntimeException();
        maxTimes = 5;
    }};

    final List<NameResolverEvent<?>> events = runTest(resolver, 5);

    // allow for an off by 1
    assertTrue(events.size() >= 4);
    assertTrue(events.size() <= 5);

    for (final NameResolverEvent<?> event : events) {
        assertEquals(NameResolverEventType.ON_ERROR, event.type);

        final Status s = (Status) event.payload;
        assertEquals(Status.UNAVAILABLE.getCode(), s.getCode());
        assertTrue(s.getCause() instanceof RuntimeException);
    }
}
 
开发者ID:indeedeng-alpha,项目名称:indeed-grpc-java,代码行数:23,代码来源:ConsulNameResolverTest.java


示例5: beforeClass

import com.ecwid.consul.v1.QueryParams; //导入依赖的package包/类
@BeforeClass
public static void beforeClass() {

	assumeTrue(CanConnect.to(new InetSocketAddress(CONSUL_HOST, CONSUL_PORT)));

	ConsulClient client = new ConsulClient();

	Response<List<CatalogService>> response = client.getCatalogService("vault",
			QueryParams.DEFAULT);

	if (response.getValue().isEmpty()) {

		NewService service = new NewService();
		service.setAddress("localhost");
		service.setPort(8200);
		service.setId("vault");
		service.setName("vault");

		client.agentServiceRegister(service);
	}
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-vault,代码行数:22,代码来源:DiscoveryBootstrapConfigurationTests.java


示例6: getKVBinaryValues

import com.ecwid.consul.v1.QueryParams; //导入依赖的package包/类
@Override
public Response<List<GetBinaryValue>> getKVBinaryValues(String keyPrefix, String token, QueryParams queryParams) {
	UrlParameters recurseParam = new SingleUrlParameters("recurse");
	UrlParameters tokenParam = token != null ? new SingleUrlParameters("token", token) : null;
	RawResponse rawResponse = rawClient.makeGetRequest("/v1/kv/" + keyPrefix, recurseParam, tokenParam, queryParams);

	if (rawResponse.getStatusCode() == 200) {
		List<GetBinaryValue> value = GsonFactory.getGson().fromJson(rawResponse.getContent(), new TypeToken<List<GetBinaryValue>>() {
		}.getType());
		return new Response<List<GetBinaryValue>>(value, rawResponse);
	} else if (rawResponse.getStatusCode() == 404) {
		return new Response<List<GetBinaryValue>>(null, rawResponse);
	} else {
		throw new OperationException(rawResponse);
	}
}
 
开发者ID:flyaruu,项目名称:tasman,代码行数:17,代码来源:KeyValueConsulClient.java


示例7: getSessionInfo

import com.ecwid.consul.v1.QueryParams; //导入依赖的package包/类
@Override
public Response<Session> getSessionInfo(String session, QueryParams queryParams) {
	RawResponse rawResponse = rawClient.makeGetRequest("/v1/session/info/" + session, queryParams);

	if (rawResponse.getStatusCode() == 200) {
		List<Session> value = GsonFactory.getGson().fromJson(rawResponse.getContent(), new TypeToken<List<Session>>() {
		}.getType());

		if (value.isEmpty()) {
			return new Response<Session>(null, rawResponse);
		} else if (value.size() == 1) {
			return new Response<Session>(value.get(0), rawResponse);
		} else {
			throw new ConsulException("Strange response (list size=" + value.size() + ")");
		}
	} else {
		throw new OperationException(rawResponse);
	}
}
 
开发者ID:flyaruu,项目名称:tasman,代码行数:20,代码来源:SessionConsulClient.java


示例8: getKVKeysOnly

import com.ecwid.consul.v1.QueryParams; //导入依赖的package包/类
@Override
public Response<List<String>> getKVKeysOnly(String keyPrefix, String separator, String token, QueryParams queryParams) {
	UrlParameters separatorParam = separator != null ? new SingleUrlParameters("separator", separator) : null;
	UrlParameters tokenParam = token != null ? new SingleUrlParameters("token", token) : null;
	RawResponse rawResponse = rawClient.makeGetRequest("/v1/kv/" + keyPrefix, separatorParam, tokenParam, queryParams);

	if (rawResponse.getStatusCode() == 200) {
		List<String> value = GsonFactory.getGson().fromJson(rawResponse.getContent(), new TypeToken<List<String>>() {
		}.getType());
		return new Response<List<String>>(value, rawResponse);
	} else if (rawResponse.getStatusCode() == 404) {
		return new Response<List<String>>(null, rawResponse);
	} else {
		throw new OperationException(rawResponse);
	}
}
 
开发者ID:flyaruu,项目名称:tasman,代码行数:17,代码来源:KeyValueConsulClient.java


示例9: getKVBinaryValue

import com.ecwid.consul.v1.QueryParams; //导入依赖的package包/类
@Override
public Response<GetBinaryValue> getKVBinaryValue(String key, String token, QueryParams queryParams) {
	UrlParameters tokenParams = token != null ? new SingleUrlParameters("token", token) : null;
	RawResponse rawResponse = rawClient.makeGetRequest("/v1/kv/" + key, tokenParams, queryParams);

	if (rawResponse.getStatusCode() == 200) {
		List<GetBinaryValue> value = GsonFactory.getGson().fromJson(rawResponse.getContent(), new TypeToken<List<GetBinaryValue>>(){}.getType());

		if (value.size() == 0) {
			return new Response<GetBinaryValue>(null, rawResponse);
		} else if (value.size() == 1) {
			return new Response<GetBinaryValue>(value.get(0), rawResponse);
		} else {
			throw new ConsulException("Strange response (list size=" + value.size() + ")");
		}
	} else if (rawResponse.getStatusCode() == 404) {
		return new Response<GetBinaryValue>(null, rawResponse);
	} else {
		throw new OperationException(rawResponse);
	}
}
 
开发者ID:flyaruu,项目名称:tasman,代码行数:22,代码来源:KeyValueConsulClient.java


示例10: getKVValues

import com.ecwid.consul.v1.QueryParams; //导入依赖的package包/类
@Override
public Response<List<GetValue>> getKVValues(String keyPrefix, String token, QueryParams queryParams) {
	UrlParameters recurseParam = new SingleUrlParameters("recurse");
	UrlParameters tokenParam = token != null ? new SingleUrlParameters("token", token) : null;
	RawResponse rawResponse = rawClient.makeGetRequest("/v1/kv/" + keyPrefix, recurseParam, tokenParam, queryParams);

	if (rawResponse.getStatusCode() == 200) {
		List<GetValue> value = GsonFactory.getGson().fromJson(rawResponse.getContent(), new TypeToken<List<GetValue>>() {
		}.getType());
		return new Response<List<GetValue>>(value, rawResponse);
	} else if (rawResponse.getStatusCode() == 404) {
		return new Response<List<GetValue>>(null, rawResponse);
	} else {
		throw new OperationException(rawResponse);
	}
}
 
开发者ID:flyaruu,项目名称:tasman,代码行数:17,代码来源:KeyValueConsulClient.java


示例11: getServiceInstances

import com.ecwid.consul.v1.QueryParams; //导入依赖的package包/类
@Override
protected List<ServerInstance> getServiceInstances(String serviceName) {
    List<ServiceInstance> instances = new ArrayList<>();

    Response<List<HealthService>> healthServices = consulClient.getHealthServices(serviceName, true, QueryParams.DEFAULT);
    for (HealthService healthService : healthServices.getValue()) {
        if (isPassingChecks(healthService)) {
            String host = findHost(healthService);
            instances.add(new DefaultServiceInstance(serviceName, host,
                    healthService.getService().getPort(), false, getMetadata(healthService)));
        }
    }
    return convertToServerInstanceList(instances);
}
 
开发者ID:darren-fu,项目名称:RestyPass,代码行数:15,代码来源:CloudConsulServerContext.java


示例12: lookupHealthService

import com.ecwid.consul.v1.QueryParams; //导入依赖的package包/类
public ConsulServiceResp lookupHealthService(String serviceName, long lastConsulIndex) {
    QueryParams queryParams = new QueryParams(ConsulConstants.CONSUL_BLOCK_TIME_SECONDS, lastConsulIndex);
    Response<List<HealthService>> orgResponse = client.getHealthServices(serviceName, true, queryParams);
    if (orgResponse != null && orgResponse.getValue() != null && !orgResponse.getValue().isEmpty()) {
        List<HealthService> HealthServices = orgResponse.getValue();
        List<ConsulService> ConsulServcies = Lists.newArrayList();
        for (HealthService orgService : HealthServices) {
            Service org = orgService.getService();
            ConsulService newService = ConsulService.newSalukiService()//
                                                    .withAddress(org.getAddress())//
                                                    .withName(org.getService())//
                                                    .withId(org.getId())//
                                                    .withPort(org.getPort().toString())//
                                                    .withTags(org.getTags())//
                                                    .build();
            ConsulServcies.add(newService);
        }
        if (!ConsulServcies.isEmpty()) {
            ConsulServiceResp response = ConsulServiceResp.newResponse()//
                                                          .withValue(ConsulServcies)//
                                                          .withConsulIndex(orgResponse.getConsulIndex())//
                                                          .withConsulLastContact(orgResponse.getConsulLastContact())//
                                                          .withConsulKnowLeader(orgResponse.isConsulKnownLeader())//
                                                          .build();
            return response;
        }
    }
    return null;
}
 
开发者ID:venus-boot,项目名称:saluki,代码行数:30,代码来源:ConsulClient.java


示例13: testFixedResolution

import com.ecwid.consul.v1.QueryParams; //导入依赖的package包/类
@Test
public void testFixedResolution() throws Exception {
    final CatalogService service = new CatalogService();
    service.setAddress("localhost");
    service.setServicePort(8080);

    final List<CatalogService> services = new ArrayList<>();
    services.add(service);

    final Response<List<CatalogService>> response = composeResponse(services);

    new Expectations() {{
        catalogClient.getCatalogService(SERVICE_NAME, QueryParams.DEFAULT);
        result = response;
        times = 1;
    }};

    final List<NameResolverEvent<?>> events = runTest(resolver, 1);
    assertEquals(1, events.size());

    final NameResolverEvent e  = events.get(0);
    assertEquals(NameResolverEventType.ON_ADDRESSES, e.type);

    final List<EquivalentAddressGroup> addressGroups = (List<EquivalentAddressGroup>) e.payload;
    assertEquals(1, addressGroups.size());

    final List<SocketAddress> addresses = addressGroups.get(0).getAddresses();
    assertEquals(1, addresses.size());

    final InetSocketAddress inetAddress = (InetSocketAddress) addresses.get(0);
    assertEquals("localhost", inetAddress.getHostName());
    assertEquals(8080, inetAddress.getPort());
}
 
开发者ID:indeedeng-alpha,项目名称:indeed-grpc-java,代码行数:34,代码来源:ConsulNameResolverTest.java


示例14: testRemoved

import com.ecwid.consul.v1.QueryParams; //导入依赖的package包/类
@Test
@Repeat(iterations = 5)
public void testRemoved() throws Exception {

    final Response<List<GetValue>> initialResponse = randomListGetValueResponse();
    final GetValue removed = initialResponse.getValue().get(randomInt(initialResponse.getValue().size() -1));
    final List<GetValue> updatedList = Lists.newArrayList(initialResponse.getValue());
    updatedList.remove(removed);
    final Response<List<GetValue>> initialResponseMinus = randomResponse(updatedList);
    //noinspection unchecked
    when(client.getKVValues(eq(rootPath), any(QueryParams.class))).thenReturn(initialResponse, initialResponseMinus);

    UpdateListener listener = new UpdateListener();
    configSource.addUpdateListener(listener);


    configSource.runOnce();

    assertThat(configSource.getLatestIndex(), is(initialResponse.getConsulIndex()));

    configSource.runOnce();

    assertThat(configSource.getLatestIndex(), is(initialResponseMinus.getConsulIndex()));
    assertThat(listener.events.get(), is(2));
    assertThat(configSource.getCurrentData().values(), not(hasItem(decodeVal(removed.getValue()))));

    WatchedUpdateResult result = listener.results.get(1);
    assertThat(result.getDeleted().values(), hasItem(decodeVal(removed.getValue())));
    assertThat(result.getAdded().isEmpty(), is(true));
    assertThat(result.getChanged().isEmpty(), is(true));
    assertThat(result.isIncremental(), is(true));


}
 
开发者ID:boundary,项目名称:archaius-consul,代码行数:35,代码来源:ConsulWatchedConfigurationSourceTest.java


示例15: deleteKVValues

import com.ecwid.consul.v1.QueryParams; //导入依赖的package包/类
@Override
public Response<Void> deleteKVValues(String key, String token, QueryParams queryParams) {
	UrlParameters recurseParam = new SingleUrlParameters("recurse");
	UrlParameters tokenParam = token != null ? new SingleUrlParameters("token", token) : null;
	RawResponse rawResponse = rawClient.makeDeleteRequest("/v1/kv/" + key, tokenParam, recurseParam, queryParams);

	if (rawResponse.getStatusCode() == 200) {
		return new Response<Void>(null, rawResponse);
	} else {
		throw new OperationException(rawResponse);
	}
}
 
开发者ID:flyaruu,项目名称:tasman,代码行数:13,代码来源:KeyValueConsulClient.java


示例16: deleteKVValue

import com.ecwid.consul.v1.QueryParams; //导入依赖的package包/类
@Override
public Response<Void> deleteKVValue(String key, String token, QueryParams queryParams) {
	UrlParameters tokenParam = token != null ? new SingleUrlParameters("token", token) : null;
	RawResponse rawResponse = rawClient.makeDeleteRequest("/v1/kv/" + key, tokenParam, queryParams);

	if (rawResponse.getStatusCode() == 200) {
		return new Response<Void>(null, rawResponse);
	} else {
		throw new OperationException(rawResponse);
	}
}
 
开发者ID:flyaruu,项目名称:tasman,代码行数:12,代码来源:KeyValueConsulClient.java


示例17: getCatalogServices

import com.ecwid.consul.v1.QueryParams; //导入依赖的package包/类
@Override
public Response<Map<String, List<String>>> getCatalogServices(QueryParams queryParams) {
	RawResponse rawResponse = rawClient.makeGetRequest("/v1/catalog/services", queryParams);

	if (rawResponse.getStatusCode() == 200) {
		Map<String, List<String>> value = GsonFactory.getGson().fromJson(rawResponse.getContent(), new TypeToken<Map<String, List<String>>>() {
		}.getType());
		return new Response<Map<String, List<String>>>(value, rawResponse);
	} else {
		throw new OperationException(rawResponse);
	}
}
 
开发者ID:flyaruu,项目名称:tasman,代码行数:13,代码来源:CatalogConsulClient.java


示例18: getCatalogService

import com.ecwid.consul.v1.QueryParams; //导入依赖的package包/类
@Override
public Response<List<com.ecwid.consul.v1.catalog.model.CatalogService>> getCatalogService(String serviceName, String tag, QueryParams queryParams) {
	UrlParameters tagParam = tag != null ? new SingleUrlParameters("tag", tag) : null;
	RawResponse rawResponse = rawClient.makeGetRequest("/v1/catalog/service/" + serviceName, tagParam, queryParams);

	if (rawResponse.getStatusCode() == 200) {
		List<com.ecwid.consul.v1.catalog.model.CatalogService> value = GsonFactory.getGson().fromJson(rawResponse.getContent(), new TypeToken<List<com.ecwid.consul.v1.catalog.model.CatalogService>>() {
		}.getType());
		return new Response<List<com.ecwid.consul.v1.catalog.model.CatalogService>>(value, rawResponse);
	} else {
		throw new OperationException(rawResponse);
	}
}
 
开发者ID:flyaruu,项目名称:tasman,代码行数:14,代码来源:CatalogConsulClient.java


示例19: getCatalogNode

import com.ecwid.consul.v1.QueryParams; //导入依赖的package包/类
@Override
public Response<CatalogNode> getCatalogNode(String nodeName, QueryParams queryParams) {
	RawResponse rawResponse = rawClient.makeGetRequest("/v1/catalog/node/" + nodeName, queryParams);

	if (rawResponse.getStatusCode() == 200) {
		CatalogNode catalogNode = GsonFactory.getGson().fromJson(rawResponse.getContent(), CatalogNode.class);
		return new Response<CatalogNode>(catalogNode, rawResponse);
	} else {
		throw new OperationException(rawResponse);
	}
}
 
开发者ID:flyaruu,项目名称:tasman,代码行数:12,代码来源:CatalogConsulClient.java


示例20: setKVValue

import com.ecwid.consul.v1.QueryParams; //导入依赖的package包/类
@Override
public Response<Boolean> setKVValue(String key, String value, String token, PutParams putParams, QueryParams queryParams) {
	UrlParameters tokenParam = token != null ? new SingleUrlParameters("token", token) : null;
	RawResponse rawResponse = rawClient.makePutRequest("/v1/kv/" + key, value, putParams, tokenParam, queryParams);

	if (rawResponse.getStatusCode() == 200) {
		boolean result = GsonFactory.getGson().fromJson(rawResponse.getContent(), boolean.class);
		return new Response<Boolean>(result, rawResponse);
	} else {
		throw new OperationException(rawResponse);
	}
}
 
开发者ID:flyaruu,项目名称:tasman,代码行数:13,代码来源:KeyValueConsulClient.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ZPath类代码示例发布时间:2022-05-22
下一篇:
Java DateTickUnitType类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap