本文整理汇总了Java中org.apache.hadoop.hbase.rest.model.VersionModel类的典型用法代码示例。如果您正苦于以下问题:Java VersionModel类的具体用法?Java VersionModel怎么用?Java VersionModel使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
VersionModel类属于org.apache.hadoop.hbase.rest.model包,在下文中一共展示了VersionModel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: validate
import org.apache.hadoop.hbase.rest.model.VersionModel; //导入依赖的package包/类
private static void validate(VersionModel model) {
assertNotNull(model);
assertNotNull(model.getRESTVersion());
assertEquals(model.getRESTVersion(), RESTServlet.VERSION_STRING);
String osVersion = model.getOSVersion();
assertNotNull(osVersion);
assertTrue(osVersion.contains(System.getProperty("os.name")));
assertTrue(osVersion.contains(System.getProperty("os.version")));
assertTrue(osVersion.contains(System.getProperty("os.arch")));
String jvmVersion = model.getJVMVersion();
assertNotNull(jvmVersion);
assertTrue(jvmVersion.contains(System.getProperty("java.vm.vendor")));
assertTrue(jvmVersion.contains(System.getProperty("java.version")));
assertTrue(jvmVersion.contains(System.getProperty("java.vm.version")));
assertNotNull(model.getServerVersion());
String jerseyVersion = model.getJerseyVersion();
assertNotNull(jerseyVersion);
assertEquals(jerseyVersion, ServletContainer.class.getPackage()
.getImplementationVersion());
}
示例2: validate
import org.apache.hadoop.hbase.rest.model.VersionModel; //导入依赖的package包/类
private static void validate(VersionModel model) {
assertNotNull(model);
assertNotNull(model.getRESTVersion());
assertEquals(RESTServlet.VERSION_STRING, model.getRESTVersion());
String osVersion = model.getOSVersion();
assertNotNull(osVersion);
assertTrue(osVersion.contains(System.getProperty("os.name")));
assertTrue(osVersion.contains(System.getProperty("os.version")));
assertTrue(osVersion.contains(System.getProperty("os.arch")));
String jvmVersion = model.getJVMVersion();
assertNotNull(jvmVersion);
assertTrue(jvmVersion.contains(System.getProperty("java.vm.vendor")));
assertTrue(jvmVersion.contains(System.getProperty("java.version")));
assertTrue(jvmVersion.contains(System.getProperty("java.vm.version")));
assertNotNull(model.getServerVersion());
String jerseyVersion = model.getJerseyVersion();
assertNotNull(jerseyVersion);
// TODO: fix when we actually get a jersey version
// assertEquals(jerseyVersion, ServletContainer.class.getPackage().getImplementationVersion());
}
示例3: get
import org.apache.hadoop.hbase.rest.model.VersionModel; //导入依赖的package包/类
/**
* Build a response for a version request.
* @param context servlet context
* @param uriInfo (JAX-RS context variable) request URL
* @return a response for a version request
*/
@GET
@Produces({MIMETYPE_TEXT, MIMETYPE_XML, MIMETYPE_JSON, MIMETYPE_PROTOBUF,
MIMETYPE_PROTOBUF_IETF})
public Response get(final @Context ServletContext context,
final @Context UriInfo uriInfo) {
if (LOG.isDebugEnabled()) {
LOG.debug("GET " + uriInfo.getAbsolutePath());
}
servlet.getMetrics().incrementRequests(1);
ResponseBuilder response = Response.ok(new VersionModel(context));
response.cacheControl(cacheControl);
servlet.getMetrics().incrementSucessfulGetRequests(1);
return response.build();
}
示例4: getRestVersion
import org.apache.hadoop.hbase.rest.model.VersionModel; //导入依赖的package包/类
/**
* @return string representing the rest api's version
* @throws IOException
* if the endpoint does not exist, there is a timeout, or some other
* general failure mode
*/
public VersionModel getRestVersion() throws IOException {
StringBuilder path = new StringBuilder();
path.append('/');
if (accessToken != null) {
path.append(accessToken);
path.append('/');
}
path.append("version/rest");
int code = 0;
for (int i = 0; i < maxRetries; i++) {
Response response = client.get(path.toString(),
Constants.MIMETYPE_PROTOBUF);
code = response.getCode();
switch (code) {
case 200:
VersionModel v = new VersionModel();
return (VersionModel) v.getObjectFromMessage(response.getBody());
case 404:
throw new IOException("REST version not found");
case 509:
try {
Thread.sleep(sleepTime);
} catch (InterruptedException e) {
throw (InterruptedIOException)new InterruptedIOException().initCause(e);
}
break;
default:
throw new IOException("get request to " + path.toString()
+ " returned " + code);
}
}
throw new IOException("get request to " + path.toString() + " timed out");
}
示例5: setUpBeforeClass
import org.apache.hadoop.hbase.rest.model.VersionModel; //导入依赖的package包/类
@BeforeClass
public static void setUpBeforeClass() throws Exception {
TEST_UTIL.startMiniCluster();
REST_TEST_UTIL.startServletContainer(TEST_UTIL.getConfiguration());
client = new Client(new Cluster().add("localhost",
REST_TEST_UTIL.getServletPort()));
context = JAXBContext.newInstance(
VersionModel.class,
StorageClusterVersionModel.class);
}
示例6: testGetStargateVersionXML
import org.apache.hadoop.hbase.rest.model.VersionModel; //导入依赖的package包/类
@Test
public void testGetStargateVersionXML() throws IOException, JAXBException {
Response response = client.get("/version", Constants.MIMETYPE_XML);
assertTrue(response.getCode() == 200);
assertEquals(Constants.MIMETYPE_XML, response.getHeader("content-type"));
VersionModel model = (VersionModel)
context.createUnmarshaller().unmarshal(
new ByteArrayInputStream(response.getBody()));
validate(model);
LOG.info("success retrieving Stargate version as XML");
}
示例7: getRestVersion
import org.apache.hadoop.hbase.rest.model.VersionModel; //导入依赖的package包/类
/**
* @return string representing the rest api's version
* @throws IOEXception
* if the endpoint does not exist, there is a timeout, or some other
* general failure mode
*/
public VersionModel getRestVersion() throws IOException {
StringBuilder path = new StringBuilder();
path.append('/');
if (accessToken != null) {
path.append(accessToken);
path.append('/');
}
path.append("version/rest");
int code = 0;
for (int i = 0; i < maxRetries; i++) {
Response response = client.get(path.toString(),
Constants.MIMETYPE_PROTOBUF);
code = response.getCode();
switch (code) {
case 200:
VersionModel v = new VersionModel();
return (VersionModel) v.getObjectFromMessage(response.getBody());
case 404:
throw new IOException("REST version not found");
case 509:
try {
Thread.sleep(sleepTime);
} catch (InterruptedException e) {
}
break;
default:
throw new IOException("get request to " + path.toString()
+ " returned " + code);
}
}
throw new IOException("get request to " + path.toString() + " timed out");
}
示例8: testGetRestVersion
import org.apache.hadoop.hbase.rest.model.VersionModel; //导入依赖的package包/类
@Test
public void testGetRestVersion() throws Exception {
VersionModel RETURNED_REST_VERSION = remoteAdmin.getRestVersion();
System.out.print("Returned version is: " + RETURNED_REST_VERSION);
// Assert that it contains info about rest version, OS, JVM
assertTrue("Returned REST version did not contain info about rest.",
RETURNED_REST_VERSION.toString().contains("rest"));
assertTrue("Returned REST version did not contain info about the JVM.",
RETURNED_REST_VERSION.toString().contains("JVM"));
assertTrue("Returned REST version did not contain info about OS.",
RETURNED_REST_VERSION.toString().contains("OS"));
}
示例9: testGetStargateVersionXML
import org.apache.hadoop.hbase.rest.model.VersionModel; //导入依赖的package包/类
@Test
public void testGetStargateVersionXML() throws IOException, JAXBException {
Response response = client.get("/version", Constants.MIMETYPE_XML);
assertTrue(response.getCode() == 200);
assertEquals(Constants.MIMETYPE_XML, response.getHeader("content-type"));
VersionModel model = (VersionModel)
context.createUnmarshaller().unmarshal(
new ByteArrayInputStream(response.getBody()));
validate(model);
}
示例10: main
import org.apache.hadoop.hbase.rest.model.VersionModel; //导入依赖的package包/类
public static void main(String[] args) throws Exception
{
Cluster cluster = new Cluster();
for (String arg : args)
cluster.add(arg, 8088);
Client client = new Client(cluster);
RemoteAdmin remoteAdmin = new RemoteAdmin(client, new Configuration());
VersionModel restVersion = remoteAdmin.getRestVersion();
System.out.println(restVersion.toString());
}
示例11: get
import org.apache.hadoop.hbase.rest.model.VersionModel; //导入依赖的package包/类
/**
* Build a response for a version request.
* @param context servlet context
* @param uriInfo (JAX-RS context variable) request URL
* @return a response for a version request
*/
@GET
@Produces({MIMETYPE_TEXT, MIMETYPE_XML, MIMETYPE_JSON, MIMETYPE_PROTOBUF,
MIMETYPE_PROTOBUF_IETF})
public Response get(final @Context ServletContext context,
final @Context UriInfo uriInfo) {
if (LOG.isTraceEnabled()) {
LOG.trace("GET " + uriInfo.getAbsolutePath());
}
servlet.getMetrics().incrementRequests(1);
ResponseBuilder response = Response.ok(new VersionModel(context));
response.cacheControl(cacheControl);
servlet.getMetrics().incrementSucessfulGetRequests(1);
return response.build();
}
示例12: setUpBeforeClass
import org.apache.hadoop.hbase.rest.model.VersionModel; //导入依赖的package包/类
@BeforeClass
public static void setUpBeforeClass() throws Exception {
TEST_UTIL.startMiniCluster();
REST_TEST_UTIL.startServletContainer(TEST_UTIL.getConfiguration());
client = new Client(new Cluster().add("localhost",
REST_TEST_UTIL.getServletPort()));
context = JAXBContext.newInstance(
VersionModel.class,
StorageClusterVersionModel.class);
}
示例13: testGetStargateVersionXML
import org.apache.hadoop.hbase.rest.model.VersionModel; //导入依赖的package包/类
@Test
public void testGetStargateVersionXML() throws IOException, JAXBException {
Response response = client.get("/version", Constants.MIMETYPE_XML);
assertEquals(200, response.getCode());
assertEquals(Constants.MIMETYPE_XML, response.getHeader("content-type"));
VersionModel model = (VersionModel)
context.createUnmarshaller().unmarshal(
new ByteArrayInputStream(response.getBody()));
validate(model);
LOG.info("success retrieving Stargate version as XML");
}
示例14: testGetStargateVersionJSON
import org.apache.hadoop.hbase.rest.model.VersionModel; //导入依赖的package包/类
@Test
public void testGetStargateVersionJSON() throws IOException {
Response response = client.get("/version", Constants.MIMETYPE_JSON);
assertEquals(200, response.getCode());
assertEquals(Constants.MIMETYPE_JSON, response.getHeader("content-type"));
ObjectMapper mapper = new JacksonJaxbJsonProvider()
.locateMapper(VersionModel.class, MediaType.APPLICATION_JSON_TYPE);
VersionModel model
= mapper.readValue(response.getBody(), VersionModel.class);
validate(model);
LOG.info("success retrieving Stargate version as JSON");
}
示例15: get
import org.apache.hadoop.hbase.rest.model.VersionModel; //导入依赖的package包/类
/**
* Build a response for a version request.
* @param context servlet context
* @param uriInfo (JAX-RS context variable) request URL
* @return a response for a version request
*/
@GET
@Produces({MIMETYPE_TEXT, MIMETYPE_XML, MIMETYPE_JSON, MIMETYPE_PROTOBUF})
public Response get(final @Context ServletContext context,
final @Context UriInfo uriInfo) {
if (LOG.isDebugEnabled()) {
LOG.debug("GET " + uriInfo.getAbsolutePath());
}
servlet.getMetrics().incrementRequests(1);
ResponseBuilder response = Response.ok(new VersionModel(context));
response.cacheControl(cacheControl);
return response.build();
}