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


Java RawResponse.getStatusCode方法代码示例

本文整理汇总了Java中com.ecwid.consul.transport.RawResponse.getStatusCode方法的典型用法代码示例。如果您正苦于以下问题:Java RawResponse.getStatusCode方法的具体用法?Java RawResponse.getStatusCode怎么用?Java RawResponse.getStatusCode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.ecwid.consul.transport.RawResponse的用法示例。


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

示例1: catalogDeregister

import com.ecwid.consul.transport.RawResponse; //导入方法依赖的package包/类
@Override
public Response<Void> catalogDeregister(CatalogDeregistration catalogDeregistration, CatalogDeregistration... catalogDeregistrations) {
	List<CatalogDeregistration> items = new ArrayList<CatalogDeregistration>();
	items.add(catalogDeregistration);
	if (catalogDeregistrations != null) {
		items.addAll(Arrays.asList(catalogDeregistrations));
	}
	String json = GsonFactory.getGson().toJson(items);

	RawResponse rawResponse = rawClient.makePutRequest("/v1/catalog/deregister", json);
	if (rawResponse.getStatusCode() == 200) {
		return new Response<Void>(null, rawResponse);
	} else {
		throw new OperationException(rawResponse);
	}
}
 
开发者ID:flyaruu,项目名称:tasman,代码行数:17,代码来源:CatalogConsulClient.java

示例2: getKVValue

import com.ecwid.consul.transport.RawResponse; //导入方法依赖的package包/类
@Override
public Response<GetValue> getKVValue(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<GetValue> value = GsonFactory.getGson().fromJson(rawResponse.getContent(), new TypeToken<List<GetValue>>(){}.getType());

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

示例3: renewSession

import com.ecwid.consul.transport.RawResponse; //导入方法依赖的package包/类
public Response<Session> renewSession(String session, QueryParams queryParams) {
	RawResponse rawResponse = rawClient.makePutRequest("/v1/session/renew/" + session, "", queryParams);

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

		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,代码行数:17,代码来源:SessionConsulClient.java

示例4: getKVBinaryValues

import com.ecwid.consul.transport.RawResponse; //导入方法依赖的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

示例5: getSessionInfo

import com.ecwid.consul.transport.RawResponse; //导入方法依赖的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

示例6: getKVValue

import com.ecwid.consul.transport.RawResponse; //导入方法依赖的package包/类
@Override
public Response<GetValue> getKVValue(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<GetValue> value = GsonFactory.getGson().fromJson(rawResponse.getContent(), new TypeToken<List<GetValue>>() {
		}.getType());

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

示例7: getCatalogService

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

	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:Ecwid,项目名称:consul-api,代码行数:17,代码来源:CatalogConsulClient.java

示例8: getKVKeysOnly

import com.ecwid.consul.transport.RawResponse; //导入方法依赖的package包/类
@Override
public Response<List<String>> getKVKeysOnly(String keyPrefix, String separator, String token, QueryParams queryParams) {
	UrlParameters keysParam = new SingleUrlParameters("keys");
	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, keysParam, 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:Ecwid,项目名称:consul-api,代码行数:18,代码来源:KeyValueConsulClient.java

示例9: getSessionInfo

import com.ecwid.consul.transport.RawResponse; //导入方法依赖的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 == null || 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:Ecwid,项目名称:consul-api,代码行数:20,代码来源:SessionConsulClient.java

示例10: getHealthChecksState

import com.ecwid.consul.transport.RawResponse; //导入方法依赖的package包/类
@Override
public Response<List<Check>> getHealthChecksState(Check.CheckStatus checkStatus, QueryParams queryParams) {
	String status = checkStatus == null ? "ANY" : checkStatus.name().toLowerCase();
	RawResponse rawResponse = rawClient.makeGetRequest("/v1/health/state/" + status, queryParams);

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

示例11: agentCheckWarn

import com.ecwid.consul.transport.RawResponse; //导入方法依赖的package包/类
@Override
public Response<Void> agentCheckWarn(String checkId, String note) {
	UrlParameters noteParams = note != null ? new SingleUrlParameters("note", note) : null;
	RawResponse rawResponse = rawClient.makeGetRequest("/v1/agent/check/warn/" + checkId, noteParams);

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

示例12: agentCheckPass

import com.ecwid.consul.transport.RawResponse; //导入方法依赖的package包/类
@Override
public Response<Void> agentCheckPass(String checkId, String note) {
	UrlParameters noteParams = note != null ? new SingleUrlParameters("note", note) : null;
	RawResponse rawResponse = rawClient.makeGetRequest("/v1/agent/check/pass/" + checkId, noteParams);

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

示例13: deleteKVValue

import com.ecwid.consul.transport.RawResponse; //导入方法依赖的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

示例14: agentCheckFail

import com.ecwid.consul.transport.RawResponse; //导入方法依赖的package包/类
@Override
public Response<Void> agentCheckFail(String checkId, String note) {
	UrlParameters noteParams = note != null ? new SingleUrlParameters("note", note) : null;
	RawResponse rawResponse = rawClient.makeGetRequest("/v1/agent/check/fail/" + checkId, noteParams);

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

示例15: aclClone

import com.ecwid.consul.transport.RawResponse; //导入方法依赖的package包/类
@Override
public Response<String> aclClone(String aclId, String token) {
	UrlParameters tokenParams = token != null ? new SingleUrlParameters("token", token) : null;
	RawResponse rawResponse = rawClient.makePutRequest("/v1/acl/clone/" + aclId, "", tokenParams);

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


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