本文整理汇总了Java中org.apache.avro.ipc.specific.SpecificResponder类的典型用法代码示例。如果您正苦于以下问题:Java SpecificResponder类的具体用法?Java SpecificResponder怎么用?Java SpecificResponder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SpecificResponder类属于org.apache.avro.ipc.specific包,在下文中一共展示了SpecificResponder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: AvroRpcWorkflowManager
import org.apache.avro.ipc.specific.SpecificResponder; //导入依赖的package包/类
public AvroRpcWorkflowManager(int port){
LOG.log(Level.INFO, "Starting workflow manager on port: "+port+" as "
+ System.getProperty("user.name", "unknown"));
Preconditions.checkArgument(port > 0, "Must specify a port greater than 0");
webServerPort = port;
LOG.log(Level.INFO, "Getting workflow engine");
engine = getWorkflowEngineFromProperty();
LOG.log(Level.INFO, "Setting workflow engine url:"+safeGetUrlFromString("http://"
+ getHostname() + ":" + this.webServerPort).toString());
if(engine == null){
throw new NullPointerException("null engine");
}
engine.setWorkflowManagerUrl(safeGetUrlFromString("http://" + getHostname() + ":" + this.webServerPort));
repo = getWorkflowRepositoryFromProperty();
LOG.log(Level.INFO, "Starting Netty Server");
// start up the server
server = new NettyServer(new SpecificResponder(
org.apache.oodt.cas.workflow.struct.avrotypes.WorkflowManager.class,this),
new InetSocketAddress(this.webServerPort));
LOG.log(Level.INFO, "GOOOOO!");
server.start();
LOG.log(Level.INFO, "Workflow Manager started by "
+ System.getProperty("user.name", "unknown"));
}
示例2: main
import org.apache.avro.ipc.specific.SpecificResponder; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
if (args[0].equals("-server")) {
NettyServer server = new NettyServer(
new SpecificResponder(HelloWorld.class, new HelloWorldImpl()),
new InetSocketAddress(7000)
);
} else {
NettyTransceiver client = new NettyTransceiver(
new InetSocketAddress(args[1], 7000)
);
HelloWorld hello = SpecificRequestor.getClient(HelloWorld.class, client);
System.out.println(
hello.send(
Request.newBuilder().setName(args[2]).build(),
20,
Status.SYM1
).getNameToReturn()
);
client.close();
}
}
示例3: startTestFlumeServer
import org.apache.avro.ipc.specific.SpecificResponder; //导入依赖的package包/类
public static Server startTestFlumeServer(int port) {
Responder responder = new SpecificResponder(AvroSourceProtocol.class,
new OKAvroHandler());
Server server = new NettyServer(responder,
new InetSocketAddress("127.0.0.1", port));
server.start();
LOG.info("Server started on test flume server hostname: localhost, port: " + port);
try {
Thread.sleep(1000L);
} catch (InterruptedException ex) {
LOG.error("Thread interrupted. Exception follows.", ex);
Thread.currentThread().interrupt();
}
return server;
}
示例4: start
import org.apache.avro.ipc.specific.SpecificResponder; //导入依赖的package包/类
@Override
public void start() {
logger.info("Starting {}...", this);
Responder responder = new SpecificResponder(AvroSourceProtocol.class, this);
NioServerSocketChannelFactory socketChannelFactory = initSocketChannelFactory();
ChannelPipelineFactory pipelineFactory = initChannelPipelineFactory();
server = new NettyServer(responder, new InetSocketAddress(bindAddress, port),
socketChannelFactory, pipelineFactory, null);
connectionCountUpdater = Executors.newSingleThreadScheduledExecutor();
server.start();
sourceCounter.start();
super.start();
final NettyServer srv = (NettyServer)server;
connectionCountUpdater.scheduleWithFixedDelay(new Runnable() {
@Override
public void run() {
sourceCounter.setOpenConnectionCount(
Long.valueOf(srv.getNumActiveConnections()));
}
}, 0, 60, TimeUnit.SECONDS);
logger.info("Avro source {} started.", getName());
}
示例5: createServer
import org.apache.avro.ipc.specific.SpecificResponder; //导入依赖的package包/类
private Server createServer(AvroSourceProtocol protocol)
throws IllegalAccessException, InstantiationException {
Server server = new NettyServer(new SpecificResponder(
AvroSourceProtocol.class, protocol), new InetSocketAddress(
hostname, port));
return server;
}
示例6: createSslServer
import org.apache.avro.ipc.specific.SpecificResponder; //导入依赖的package包/类
private Server createSslServer(AvroSourceProtocol protocol)
throws IllegalAccessException, InstantiationException {
Server server = new NettyServer(new SpecificResponder(
AvroSourceProtocol.class, protocol), new InetSocketAddress(hostname, port),
new NioServerSocketChannelFactory(
Executors.newCachedThreadPool(),
Executors.newCachedThreadPool()),
new SSLChannelPipelineFactory(),
null);
return server;
}
示例7: start
import org.apache.avro.ipc.specific.SpecificResponder; //导入依赖的package包/类
@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();
}
示例8: setUp
import org.apache.avro.ipc.specific.SpecificResponder; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
headers = Maps.newHashMap();
headers.put("key1", "value1");
body = "body".getBytes(Charsets.UTF_8);
int port = findFreePort();
eventCollector = new EventCollector();
Responder responder = new SpecificResponder(AvroSourceProtocol.class,
eventCollector);
nettyServer = new NettyServer(responder,
new InetSocketAddress(HOSTNAME, port));
nettyServer.start();
// give the server a second to start
Thread.sleep(1000L);
properties = Maps.newHashMap();
properties.put("channel.type", "memory");
properties.put("channel.capacity", "200");
properties.put("sinks", "sink1 sink2");
properties.put("sink1.type", "avro");
properties.put("sink2.type", "avro");
properties.put("sink1.hostname", HOSTNAME);
properties.put("sink1.port", String.valueOf(port));
properties.put("sink2.hostname", HOSTNAME);
properties.put("sink2.port", String.valueOf(port));
properties.put("processor.type", "load_balance");
agent = new EmbeddedAgent("test-" + serialNumber.incrementAndGet());
}
示例9: MemberNettyRPCToolsBuilderServer
import org.apache.avro.ipc.specific.SpecificResponder; //导入依赖的package包/类
/**
* Java工具生成协议代码方式:java -jar E:\avro\avro-tools-1.7.7.jar compile protocol E:\avro\Members.avpr E:\avro
* 功能和动态调用方式一致
* @throws InterruptedException
*/
public void MemberNettyRPCToolsBuilderServer() throws InterruptedException{
//1.构造接口和实现类的映射相应对象,MemberIFaceImpl该类为具体的业务实现类
SpecificResponder responder=new SpecificResponder(MemberIFace.class, new MemberIFaceImpl());
//2.Netty启动RPC服务
Server server=new NettyServer(responder, new InetSocketAddress(60090));
server.start();
System.out.println("Tools Builder PRC Start Complete.");
server.join();
}
示例10: doMain
import org.apache.avro.ipc.specific.SpecificResponder; //导入依赖的package包/类
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();
}
示例11: createHttpServer
import org.apache.avro.ipc.specific.SpecificResponder; //导入依赖的package包/类
private Server createHttpServer(int port, String name, int maxThreads, int maxIdleTimeMs) throws BioNimbusException {
try {
// Creates HTTP Server on int port
Server httpServer = new Server(port);
SpecificResponder responder = new SpecificResponder(BioProto.class, bioProto);
// QueuedThreadPool is jetty's thread pool implementation;
// this lets us give it a name.
QueuedThreadPool qtp = new QueuedThreadPool();
qtp.setName(name);
qtp.setDaemon(true);
qtp.setMaxThreads(maxThreads);
qtp.setMaxIdleTimeMs(maxIdleTimeMs);
httpServer.setThreadPool(qtp);
// Creates Responder Servlet
Servlet servlet = new ResponderServlet(responder);
// Creates Context adding a holder
new Context(httpServer, "/").addServlet(new ServletHolder(servlet), "/*");
// Return the early created Server
return httpServer;
} catch (Exception e) {
throw new BioNimbusException(e);
}
}
示例12: AvroRpcResourceManager
import org.apache.avro.ipc.specific.SpecificResponder; //导入依赖的package包/类
public AvroRpcResourceManager(int port) throws Exception{
// load properties from workflow manager properties file, if specified
if (System.getProperty("org.apache.oodt.cas.resource.properties") != null) {
String configFile = System
.getProperty("org.apache.oodt.cas.resource.properties");
LOG.log(Level.INFO,
"Loading Resource Manager Configuration Properties from: ["
+ configFile + "]");
System.getProperties().load(
new FileInputStream(new File(configFile)));
}
String schedulerClassStr = System.getProperty(
"resource.scheduler.factory",
"org.apache.oodt.cas.resource.scheduler.LRUSchedulerFactory");
scheduler = GenericResourceManagerObjectFactory
.getSchedulerServiceFromFactory(schedulerClassStr);
// start up the scheduler
new Thread(scheduler).start();
this.port = port;
// start up the web server
server = new NettyServer(new SpecificResponder(org.apache.oodt.cas.resource.structs.avrotypes.ResourceManager.class,this),
new InetSocketAddress(this.port));
server.start();
LOG.log(Level.INFO, "Resource Manager started by "
+ System.getProperty("user.name", "unknown"));
}
示例13: startUp
import org.apache.avro.ipc.specific.SpecificResponder; //导入依赖的package包/类
@Override
public boolean startUp() throws Exception {
server = new NettyServer(new SpecificResponder(AvroFileManager.class,this),new InetSocketAddress(this.port));
server.start();
try {
this.fileManager = new FileManager();
this.loadConfiguration();
} catch (Exception e) {
e.printStackTrace();
return false;
}
return true;
}
示例14: startServer
import org.apache.avro.ipc.specific.SpecificResponder; //导入依赖的package包/类
private static void startServer() throws IOException {
server = new NettyServer(new SpecificResponder(EmailSender.class, new EmailSenderImpl()),
new InetSocketAddress(65333));
}
示例15: startServer
import org.apache.avro.ipc.specific.SpecificResponder; //导入依赖的package包/类
static void startServer() throws IOException {
server = new NettyServer(new SpecificResponder(Mail.class,new MailImpl()), new InetSocketAddress(10000));
}