本文整理汇总了Java中water.api.RequestServer类的典型用法代码示例。如果您正苦于以下问题:Java RequestServer类的具体用法?Java RequestServer怎么用?Java RequestServer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RequestServer类属于water.api包,在下文中一共展示了RequestServer类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: sendLoginForm
import water.api.RequestServer; //导入依赖的package包/类
private void sendLoginForm(HttpServletRequest request, HttpServletResponse response) {
String uri = JettyHTTPD.getDecodedUri(request);
try {
byte[] bytes;
try (InputStream resource = water.init.JarHash.getResource2("/login.html")) {
if (resource == null)
throw new IllegalStateException("Login form not found");
ByteArrayOutputStream baos = new ByteArrayOutputStream();
water.util.FileUtils.copyStream(resource, baos, 2048);
bytes = baos.toByteArray();
}
response.setContentType(RequestServer.MIME_HTML);
response.setContentLength(bytes.length);
setResponseStatus(response, HttpServletResponse.SC_OK);
OutputStream os = response.getOutputStream();
water.util.FileUtils.copyStream(new ByteArrayInputStream(bytes), os, 2048);
} catch (Exception e) {
sendErrorResponse(response, e, uri);
} finally {
logRequest("GET", request, response);
}
}
示例2: startNetworkServices
import water.api.RequestServer; //导入依赖的package包/类
/** Starts the worker threads, receiver threads, heartbeats and all other
* network related services. */
private static void startNetworkServices() {
// We've rebooted the JVM recently. Tell other Nodes they can ignore task
// prior tasks by us. Do this before we receive any packets
UDPRebooted.T.reboot.broadcast();
// Start the UDPReceiverThread, to listen for requests from other Cloud
// Nodes. There should be only 1 of these, and it never shuts down.
// Started first, so we can start parsing UDP packets
if(H2O.ARGS.useUDP)
new UDPReceiverThread().start();
// Start the MultiReceiverThread, to listen for multi-cast requests from
// other Cloud Nodes. There should be only 1 of these, and it never shuts
// down. Started soon, so we can start parsing multi-cast UDP packets
new MultiReceiverThread().start();
// Start the Persistent meta-data cleaner thread, which updates the K/V
// mappings periodically to disk. There should be only 1 of these, and it
// never shuts down. Needs to start BEFORE the HeartBeatThread to build
// an initial histogram state.
Cleaner.THE_CLEANER.start();
// Start a UDP timeout worker thread. This guy only handles requests for
// which we have not received a timely response and probably need to
// arrange for a re-send to cover a dropped UDP packet.
new UDPTimeOutThread().start();
new H2ONode.AckAckTimeOutThread().start();
// Start the TCPReceiverThread, to listen for TCP requests from other Cloud
// Nodes. There should be only 1 of these, and it never shuts down.
new TCPReceiverThread(NetworkInit._tcpSocketBig).start();
// Register the default Requests
Object x = water.api.RequestServer.class;
}
示例3: registerHandlers
import water.api.RequestServer; //导入依赖的package包/类
@Override
protected void registerHandlers(HandlerWrapper handlerWrapper, ServletContextHandler context) {
context.addServlet(NpsBinServlet.class, "/3/NodePersistentStorage.bin/*");
context.addServlet(PostFileServlet.class, "/3/PostFile.bin");
context.addServlet(PostFileServlet.class, "/3/PostFile");
context.addServlet(DatasetServlet.class, "/3/DownloadDataset");
context.addServlet(DatasetServlet.class, "/3/DownloadDataset.bin");
context.addServlet(PutKeyServlet.class, "/3/PutKey.bin");
context.addServlet(PutKeyServlet.class, "/3/PutKey");
context.addServlet(RequestServer.class, "/");
// Handlers that can only be invoked for an authenticated user (if auth is enabled)
HandlerCollection authHandlers = new HandlerCollection();
authHandlers.setHandlers(new Handler[]{
new AuthenticationHandler(),
new ExtensionHandler1(),
context,
});
// LoginHandler handles directly login requests and delegates the rest to the authHandlers
LoginHandler loginHandler = new LoginHandler("/login", "/loginError");
loginHandler.setHandler(authHandlers);
HandlerCollection hc = new HandlerCollection();
hc.setHandlers(new Handler[]{
new GateHandler(),
loginHandler
});
handlerWrapper.setHandler(hc);
}
示例4: setCommonResponseHttpHeaders
import water.api.RequestServer; //导入依赖的package包/类
private static void setCommonResponseHttpHeaders(HttpServletResponse response) {
response.setHeader("X-h2o-build-project-version", H2O.ABV.projectVersion());
response.setHeader("X-h2o-rest-api-version-max", Integer.toString(water.api.RequestServer.H2O_REST_API_VERSION));
response.setHeader("X-h2o-cluster-id", Long.toString(H2O.CLUSTER_ID));
response.setHeader("X-h2o-cluster-good", Boolean.toString(H2O.CLOUD.healthy()));
response.setHeader("X-h2o-context-path", sanatizeContextPath(H2O.ARGS.context_path));
}
示例5: register
import water.api.RequestServer; //导入依赖的package包/类
@Deprecated
static public void register(
String method_url, Class<? extends water.api.Handler> hclass, String method, String apiName, String summary
) {
Log.warn("The H2O.register method is deprecated and will be removed in the next major release." +
"Please register REST API endpoints as part of their corresponding REST API extensions!");
RequestServer.registerEndpoint(apiName, method_url, hclass, method, summary);
}
示例6: registerCustomPages
import water.api.RequestServer; //导入依赖的package包/类
public static void registerCustomPages() {
try {
Request r = (Request)Class.forName("cookbook.groupedaverage.GroupedAverage").newInstance();
Request.addToNavbar(RequestServer.registerRequest(r), "Grouped Average", "Grouped");
Request.initializeNavBar();
System.out.println("Pages added.");
}
catch (Exception e) {
Log.err(e);
}
}
示例7: registered
import water.api.RequestServer; //导入依赖的package包/类
@Override
protected void registered(RequestServer.API_VERSION ver) {
super.registered(ver);
for (Argument arg : _arguments) {
if ( arg._name.equals("activation") || arg._name.equals("initial_weight_distribution")
|| arg._name.equals("mode") || arg._name.equals("expert_mode")) {
arg.setRefreshOnChange();
}
}
}
示例8: serve
import water.api.RequestServer; //导入依赖的package包/类
private void serve(String s, Properties parms) {
RequestServer.SERVER.serve(s,"GET",null,parms==null?new Properties():parms);
assertFalse("Check of pre-cloud classes failed. You likely added a class to TypeMap.BOOTSTRAP_CLASSES[]. Page: " + s, Paxos._cloudLocked);
}
示例9: registerGET
import water.api.RequestServer; //导入依赖的package包/类
static public void registerGET( String url_pattern, Class hclass, String hmeth, String doc_method, String summary ) {
if( _doneRequests ) throw new IllegalArgumentException("Cannot add more Requests once the list is finalized");
RequestServer.register(url_pattern,"GET", hclass, hmeth, doc_method, summary);
}
示例10: registerPOST
import water.api.RequestServer; //导入依赖的package包/类
static public void registerPOST( String url_pattern, Class hclass, String hmeth, String summary ) {
if( _doneRequests ) throw new IllegalArgumentException("Cannot add more Requests once the list is finalized");
RequestServer.register(url_pattern,"POST",hclass,hmeth,null,summary);
}
示例11: finalizeRegistration
import water.api.RequestServer; //导入依赖的package包/类
/** Start the web service; disallow future URL registration.
* Blocks until the server is up. */
static public void finalizeRegistration() {
if (_doneRequests) return;
_doneRequests = true;
water.api.RequestServer.finalizeRegistration();
}
示例12: serve
import water.api.RequestServer; //导入依赖的package包/类
private void serve(String s, Properties parms) {
RequestServer.serve(s,"GET",null,parms==null?new Properties():parms,null);
assertFalse("Check of pre-cloud classes failed. You likely added a class to TypeMap.BOOTSTRAP_CLASSES[]. Page: " + s, Paxos._cloudLocked);
}
示例13: isPageRequest
import water.api.RequestServer; //导入依赖的package包/类
private boolean isPageRequest(HttpServletRequest request) {
String accept = request.getHeader("Accept");
return (accept != null) && accept.contains(RequestServer.MIME_HTML);
}
示例14: testIndexesVsNames
import water.api.RequestServer; //导入依赖的package包/类
@Test public void testIndexesVsNames() throws Exception {
String[] names = new String[] { "5", "2", "1", "8", "4", "100" };
double[][] items = new double[10][names.length];
for( int r = 0; r < items.length; r++ )
for( int c = 0; c < items[r].length; c++ )
items[r][c] = r;
Key key = Key.make("test");
Key dst = Key.make("dest");
Frame frame = frame(names, items);
UKV.put(key, frame);
try {
RequestServer.registerRequest(new FailTestJob());
RequestServer.registerRequest(new FailTestJobAsync());
RequestServer.registerRequest(new ArgsTestJob());
String args = "" + //
"destination_key=" + dst + "&" + //
"source=" + key + "&" + //
"response=8&" + //
"cols=2,100";
Get get;
get = get("NotRegisteredJob.json?" + args, Res.class);
Assert.assertEquals(404, get._status);
waitForJob(dst);
get = get(FailTestJob.class.getSimpleName() + ".json?" + args, Res.class);
Assert.assertEquals(500, get._status);
waitForJob(dst);
get = get(FailTestJobAsync.class.getSimpleName() + ".json?" + args, Res.class);
Assert.assertEquals(200, get._status);
String exception = waitForJob(dst);
Assert.assertTrue(exception.contains(ExpectedExceptionForDebug.class.getName()));
get = get(ArgsTestJob.class.getSimpleName() + ".json?" + args, Res.class);
Assert.assertEquals(200, get._status);
waitForJob(dst);
} finally {
RequestServer.unregisterRequest(new FailTestJob());
RequestServer.unregisterRequest(new FailTestJobAsync());
RequestServer.unregisterRequest(new ArgsTestJob());
UKV.remove(key);
}
}