org.apache.avro.ipc.HttpServer类的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(7.2k)|赞(0)|评价(0)|浏览(974)

本文整理了Java中org.apache.avro.ipc.HttpServer类的一些代码示例,展示了HttpServer类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HttpServer类的具体详情如下:
包路径:org.apache.avro.ipc.HttpServer
类名称:HttpServer

HttpServer介绍

[英]An HTTP-based RPC Server.
[中]基于HTTP的RPC服务器。

代码示例

代码示例来源:origin: apache/flume

@Override
public void start() {
 // setup http server to receive OG events
 res = new SpecificResponder(FlumeOGEventAvroServer.class, this);
 try {
  http = new HttpServer(res, host, port);
 } catch (IOException eI) {
  LOG.warn("Failed to start server", eI);
  return;
 }
 http.start();
 super.start();
}

代码示例来源:origin: apache/avro

/** Sends RPCs and returns nanos elapsed. */
private static long sendRpcs(boolean withPlugin) throws IOException {
 HttpServer server = createServer(withPlugin);
 Transceiver t =
  new HttpTransceiver(new URL("http://127.0.0.1:"+server.getPort()+"/"));
 GenericRequestor requestor = new GenericRequestor(NULL_PROTOCOL, t);
 long now = System.nanoTime();
 for (int i = 0; i < COUNT; ++i) {
  requestor.request("null", null);
 }
 long elapsed = System.nanoTime() - now;
 t.close();
 server.close();
 return elapsed;
}

代码示例来源:origin: jingwei/krati

public static void main(String[] args) throws Exception {
    File storeDir = new File(System.getProperty("java.io.tmpdir"), SingleAvroStoreHttpServer.class.getSimpleName());
    StoreResponder storeResponder = new BasicDataStoreResponder(createDataStore(storeDir, 10000));
    storeResponder.setProperty(StoreKeys.KRATI_STORE_VALUE_SCHEMA, createSchema().toString());
    HttpServer server = new HttpServer(storeResponder, 8080);
    server.start();
    server.join();
  }
}

代码示例来源:origin: apache/avro

/** Create a {@link Server} listening at the named URI using the provided
 * responder. */
public static Server createServer(Responder responder,
                 URI uri) throws IOException {
 if ("http".equals(uri.getScheme()))
  return new HttpServer(responder, uri.getPort());
 else if ("avro".equals(uri.getScheme()))
  return new SaslSocketServer
   (responder, new InetSocketAddress(uri.getHost(), uri.getPort()));
 else
  throw new IOException("unknown uri scheme: "+uri);
}

代码示例来源:origin: org.apache.cassandra.deps/avro

server = new HttpServer(new SinkResponder(protocol), uri.getPort());
server.start();
out.println("Port: " + server.getPort());
return 0;

代码示例来源:origin: org.apache.hadoop/avro

server = new HttpServer(new SinkResponder(protocol), uri.getPort());
out.println("Port: " + server.getPort());
return 0;

代码示例来源:origin: apache/flume

@Override
public void stop() {
 http.close();
 super.stop();
}

代码示例来源:origin: co.cask.hbase/hbase

protected static void doMain(final String[] args) throws Exception {
 if (args.length < 1) {
  printUsageAndExit();
 }
 int port = 9090;
 final String portArgKey = "--port=";
 for (String cmd: args) {
  if (cmd.startsWith(portArgKey)) {
   port = Integer.parseInt(cmd.substring(portArgKey.length()));
   continue;
  } else if (cmd.equals("--help") || cmd.equals("-h")) {
   printUsageAndExit();
  } else if (cmd.equals("start")) {
   continue;
  } else if (cmd.equals("stop")) {
   printUsageAndExit("To shutdown the Avro server run " +
    "bin/hbase-daemon.sh stop avro or send a kill signal to " +
    "the Avro server pid");
  }
  
  // Print out usage if we get to here.
  printUsageAndExit();
 }
 Log LOG = LogFactory.getLog("AvroServer");
 LOG.info("starting HBase Avro server on port " + Integer.toString(port));
 SpecificResponder r = new SpecificResponder(HBase.class, new HBaseImpl());
 HttpServer server = new HttpServer(r, port);
 server.start();
 server.join();
}

代码示例来源:origin: apache/avro

@Override
public Server createServer(Responder testResponder) throws Exception {
 return new HttpServer(testResponder, 0);
}

代码示例来源:origin: org.apache.cassandra.deps/avro

int run2(PrintStream err) throws InterruptedException {
 latch.await();
 err.println("Closing server.");
 server.close();
 return 0;
}

代码示例来源:origin: jingwei/krati

public static void main(String[] args) throws Exception {
    File homeDir = new File(System.getProperty("java.io.tmpdir"), MultiTenantStoreHttpServer.class.getSimpleName());
    
    // Change initialCapacity accordingly for different data sets
    int initialCapacity = 10000;
    
    // Create store configuration template
    StoreConfig configTemplate = new StoreConfig(homeDir, initialCapacity);
    configTemplate.setSegmentCompactFactor(0.68);
    configTemplate.setSegmentFactory(new MappedSegmentFactory());
    configTemplate.setSegmentFileSizeMB(32);
    configTemplate.setNumSyncBatches(2);
    configTemplate.setBatchSize(100);
    
    // Create store responder and server
    DataStoreFactory storeFactory = new IndexedDataStoreFactory();
    MultiTenantStoreResponder storeResponder = new MultiTenantStoreResponder(homeDir, configTemplate, new BasicDataStoreResponderFactory(storeFactory));
    HttpServer server = new HttpServer(storeResponder, 8080);
    server.start();
    server.join();
  }
}

代码示例来源:origin: apache/avro

/** Starts an Avro server. */
private static HttpServer createServer(boolean withPlugin)
  throws IOException {
 Responder r = new IdentityResponder(NULL_PROTOCOL);
 if (withPlugin) {
  r.addRPCPlugin(new StatsPlugin());
 }
 // Start Avro server
 HttpServer server = new HttpServer(r, 0);
 server.start();
 return server;
}

代码示例来源:origin: apache/avro

@Override
public Server createServer(Responder testResponder) throws Exception {
 System.setProperty("javax.net.ssl.keyStore", "src/test/keystore");
 System.setProperty("javax.net.ssl.keyStorePassword", "avrotest");
 System.setProperty("javax.net.ssl.password", "avrotest");
 System.setProperty("javax.net.ssl.trustStore", "src/test/truststore");
 System.setProperty("javax.net.ssl.trustStorePassword", "avrotest");
 SslConnectionFactory connectionFactory = new SslConnectionFactory("HTTP/1.1");
 SslContextFactory sslContextFactory = connectionFactory.getSslContextFactory();
 sslContextFactory.setKeyStorePath(System.getProperty("javax.net.ssl.keyStore"));
 sslContextFactory.setKeyManagerPassword(System.getProperty("javax.net.ssl.password"));
 sslContextFactory.setKeyStorePassword(System.getProperty("javax.net.ssl.keyStorePassword"));
 sslContextFactory.setNeedClientAuth(false);
 return new HttpServer(testResponder, connectionFactory, "localhost", 18443);
}

代码示例来源:origin: org.apache.hadoop/avro

int run2(PrintStream err) throws InterruptedException {
 latch.await();
 err.println("Closing server.");
 server.close();
 return 0;
}

代码示例来源:origin: jingwei/krati

HttpServer server = new HttpServer(new AvroStoreResponder<String>(joiner), 8080);
server.start();
server.join();

代码示例来源:origin: apache/avro

HttpServer avroServer = new HttpServer(r, Integer.parseInt(args[0]));
avroServer.start();

代码示例来源:origin: apache/avro

iaddress=new InetSocketAddress(0);
this.outputServer= new  HttpServer
  (new SpecificResponder(OutputProtocol.class, outputService),
    iaddress.getPort());

代码示例来源:origin: org.apache.flume.flume-ng-legacy-sources/flume-avro-source

@Override
public void stop() {
 http.close();
 super.stop();
}

代码示例来源:origin: jingwei/krati

HttpServer server = new HttpServer(new AvroStoreBusResponder<Integer>(storeBus), 8080);
server.start();
System.out.println(client.getSchema().toString(true));
server.join();

代码示例来源:origin: org.apache.flume.flume-ng-legacy-sources/flume-avro-source

@Override
public void start() {
 // setup http server to receive OG events
 res = new SpecificResponder(FlumeOGEventAvroServer.class, this);
 try {
  http = new HttpServer(res, host, port);
 } catch (IOException eI) {
  LOG.warn("Failed to start server", eI);
  return;
 }
 http.start();
 super.start();
}

相关文章