本文整理汇总了Java中org.apache.avro.ipc.specific.SpecificRequestor类的典型用法代码示例。如果您正苦于以下问题:Java SpecificRequestor类的具体用法?Java SpecificRequestor怎么用?Java SpecificRequestor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SpecificRequestor类属于org.apache.avro.ipc.specific包,在下文中一共展示了SpecificRequestor类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import org.apache.avro.ipc.specific.SpecificRequestor; //导入依赖的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();
}
}
示例2: AvroFileManagerClient
import org.apache.avro.ipc.specific.SpecificRequestor; //导入依赖的package包/类
public AvroFileManagerClient(final URL url, boolean testConnection) throws ConnectionException {
//setup the and start the client
try {
this.fileManagerUrl = url;
InetSocketAddress inetSocketAddress = new InetSocketAddress(url.getHost(),this.fileManagerUrl.getPort());
this.client = new NettyTransceiver(inetSocketAddress);
proxy = (AvroFileManager) SpecificRequestor.getClient(AvroFileManager.class, client);
} catch (IOException e) {
e.printStackTrace();
LOG.log(Level.WARNING, "IOException when connecting to filemgr: ["
+ this.fileManagerUrl + "]");
}
if (testConnection && !isAlive()) {
throw new ConnectionException("Exception connecting to filemgr: ["
+ this.fileManagerUrl + "]");
}
}
示例3: main
import org.apache.avro.ipc.specific.SpecificRequestor; //导入依赖的package包/类
public static void main(String[] args) throws IOException {
if (args.length != 3) {
System.out.println("Usage: <to> <from> <body>");
System.exit(1);
}
logger.info("Starting Server");
// usually this would be another app, but for simplicity
startServer();
logger.info("Server started");
NettyTransceiver client = new NettyTransceiver(new InetSocketAddress(65333));
// client code - attach to the server and send a message
EmailSender proxy = SpecificRequestor.getClient(EmailSender.class, client);
logger.info("Client built, got proxy");
// fill in the Message record and send it
EmailMessage message = new EmailMessage();
message.setTo(new Utf8(args[0]));
message.setFrom(new Utf8(args[1]));
message.setBody(new Utf8(args[2]));
logger.info("Calling proxy.send with message: {} ", message.toString());
logger.info("Result: {}", proxy.send(message));
// cleanup
client.close();
server.close();
}
示例4: MemberNettyRPCToolsBuilderClient
import org.apache.avro.ipc.specific.SpecificRequestor; //导入依赖的package包/类
/**
* Java工具生成协议代码方式:java -jar E:\avro\avro-tools-1.7.7.jar compile protocol
* E:\avro\Members.avpr E:\avro 功能和动态调用方式一致
*
* @throws InterruptedException
* @throws IOException
*/
public void MemberNettyRPCToolsBuilderClient() throws InterruptedException, IOException {
// 1.和服务端建立通讯
Transceiver transceiver = new NettyTransceiver(new InetSocketAddress("192.168.1.116", 60090));
// 2.获取客户端对象
MemberIFace memberIFace = SpecificRequestor.getClient(MemberIFace.class, transceiver);
// 3.进行数据设置
Members members = new Members();
members.setUserName("rita");
members.setUserPwd("123456");
// 开始调用登录方法
Retmsg retmsg = memberIFace.login(members);
System.out.println("Recive Msg:" + retmsg.getMsg());
}
示例5: initializeTranceiver
import org.apache.avro.ipc.specific.SpecificRequestor; //导入依赖的package包/类
@Override
protected void initializeTranceiver() throws IOException {
transceiver = new HttpTransceiver(new URL("http://localhost:" + avroPort));
requestor = new SpecificRequestor(KeyValueProtocol.class, transceiver);
transceiverMessageInRoute = new HttpTransceiver(new URL("http://localhost:" + avroPortMessageInRoute));
requestorMessageInRoute = new SpecificRequestor(KeyValueProtocol.class, transceiverMessageInRoute);
transceiverForWrongMessages = new HttpTransceiver(new URL("http://localhost:" + avroPortForWrongMessages));
requestorForWrongMessages = new SpecificRequestor(KeyValueProtocol.class, transceiverForWrongMessages);
reflectTransceiver = new HttpTransceiver(new URL("http://localhost:" + avroPortReflection));
reflectRequestor = new ReflectRequestor(TestReflection.class, reflectTransceiver);
}
示例6: initializeTranceiver
import org.apache.avro.ipc.specific.SpecificRequestor; //导入依赖的package包/类
@Override
protected void initializeTranceiver() throws IOException {
transceiver = new NettyTransceiver(new InetSocketAddress("localhost", avroPort));
requestor = new SpecificRequestor(KeyValueProtocol.class, transceiver);
transceiverMessageInRoute = new NettyTransceiver(new InetSocketAddress("localhost", avroPortMessageInRoute));
requestorMessageInRoute = new SpecificRequestor(KeyValueProtocol.class, transceiverMessageInRoute);
transceiverForWrongMessages = new NettyTransceiver(new InetSocketAddress("localhost", avroPortForWrongMessages));
requestorForWrongMessages = new SpecificRequestor(KeyValueProtocol.class, transceiverForWrongMessages);
reflectTransceiver = new NettyTransceiver(new InetSocketAddress("localhost", avroPortReflection));
reflectRequestor = new ReflectRequestor(TestReflection.class, reflectTransceiver);
}
示例7: main
import org.apache.avro.ipc.specific.SpecificRequestor; //导入依赖的package包/类
public static void main(String[] args) throws IOException {
if(args.length < 3){
args = new String[] {"[email protected]","[email protected]","Hello !"};
}
NettyTransceiver client = new NettyTransceiver(new InetSocketAddress(10000));
Mail proxy = (Mail) SpecificRequestor.getClient(Mail.class, client);
LogUtil.println("ClientAvroRPC built OK, got proxy, ready to send data ...");
Message message = new Message();
message.setTo(new Utf8(args[0]));
message.setFrom(new Utf8(args[1]));
message.setBody(new Utf8(args[2]));
LogUtil.println("Calling proxy.send with message: " + message.toString());
LogUtil.println("Result from server: " + proxy.send(message));
client.close();
}
示例8: getNettyTransport
import org.apache.avro.ipc.specific.SpecificRequestor; //导入依赖的package包/类
/**
* Return Netty Transport
*
* @return
*/
public BioProto getNettyTransport() {
BioProto proxy = null;
try {
nettyClient = new NettyTransceiver(new InetSocketAddress(address, port));
proxy = (BioProto) SpecificRequestor.getClient(BioProto.class, nettyClient);
} catch (IOException ex) {
LOGGER.error("[IOException] " + ex.getMessage());
}
return proxy;
}
示例9: getHttpTransport
import org.apache.avro.ipc.specific.SpecificRequestor; //导入依赖的package包/类
/**
* Return HTTP Transport
*
* @return
*/
public BioProto getHttpTransport() {
BioProto proxy = null;
try {
HttpTransceiver transceiver = new HttpTransceiver(new URL("http://" + address + ":" + port));
proxy = (BioProto) SpecificRequestor.getClient(BioProto.class, transceiver);
} catch (IOException ex) {
LOGGER.error("[IOException] " + ex.getMessage());
}
return proxy;
}
示例10: AvroRpcWorkflowManagerClient
import org.apache.avro.ipc.specific.SpecificRequestor; //导入依赖的package包/类
public AvroRpcWorkflowManagerClient(URL url){
workflowManagerUrl = url;
try {
client = new NettyTransceiver(new InetSocketAddress(url.getHost(),url.getPort()));
proxy = SpecificRequestor.getClient(org.apache.oodt.cas.workflow.struct.avrotypes.WorkflowManager.class, client);
} catch (IOException e) {
e.printStackTrace();
}
}
示例11: setWorkflowManagerUrl
import org.apache.avro.ipc.specific.SpecificRequestor; //导入依赖的package包/类
@Override
public void setWorkflowManagerUrl(URL workflowManagerUrl) {
this.workflowManagerUrl = workflowManagerUrl;
try {
client = new NettyTransceiver(new InetSocketAddress(workflowManagerUrl.getPort()));
proxy = SpecificRequestor.getClient(org.apache.oodt.cas.workflow.struct.avrotypes.WorkflowManager.class, client);
} catch (IOException e) {
e.printStackTrace();
}
}
示例12: testSslRequest
import org.apache.avro.ipc.specific.SpecificRequestor; //导入依赖的package包/类
@Test
public void testSslRequest() throws InterruptedException, IOException {
boolean bound = false;
for (int i = 0; i < 10 && !bound; i++) {
try {
Context context = new Context();
context.put("port", String.valueOf(selectedPort = 41414 + i));
context.put("bind", "0.0.0.0");
context.put("ssl", "true");
context.put("keystore", "src/test/resources/server.p12");
context.put("keystore-password", "password");
context.put("keystore-type", "PKCS12");
Configurables.configure(source, context);
source.start();
bound = true;
} catch (ChannelException e) {
/*
* NB: This assume we're using the Netty server under the hood and the
* failure is to bind. Yucky.
*/
Thread.sleep(100);
}
}
Assert
.assertTrue("Reached start or error", LifecycleController.waitForOneOf(
source, LifecycleState.START_OR_ERROR));
Assert.assertEquals("Server is started", LifecycleState.START,
source.getLifecycleState());
AvroSourceProtocol client = SpecificRequestor.getClient(
AvroSourceProtocol.class, new NettyTransceiver(new InetSocketAddress(
selectedPort), new SSLChannelFactory()));
AvroFlumeEvent avroEvent = new AvroFlumeEvent();
avroEvent.setHeaders(new HashMap<CharSequence, CharSequence>());
avroEvent.setBody(ByteBuffer.wrap("Hello avro ssl".getBytes()));
Status status = client.append(avroEvent);
Assert.assertEquals(Status.OK, status);
Transaction transaction = channel.getTransaction();
transaction.begin();
Event event = channel.take();
Assert.assertNotNull(event);
Assert.assertEquals("Channel contained our event", "Hello avro ssl",
new String(event.getBody()));
transaction.commit();
transaction.close();
logger.debug("Round trip event:{}", event);
source.stop();
Assert.assertTrue("Reached stop or error",
LifecycleController.waitForOneOf(source, LifecycleState.STOP_OR_ERROR));
Assert.assertEquals("Server is stopped", LifecycleState.STOP,
source.getLifecycleState());
}
示例13: testRequest
import org.apache.avro.ipc.specific.SpecificRequestor; //导入依赖的package包/类
@Test
public void testRequest() throws InterruptedException, IOException {
boolean bound = false;
int i;
for (i = 0; i < 100 && !bound; i++) {
try {
Context context = new Context();
context.put("port", String.valueOf(selectedPort = 41414 + i));
context.put("host", "0.0.0.0");
Configurables.configure(source, context);
source.start();
bound = true;
} catch (ChannelException e) {
// Assume port in use, try another one
}
}
Assert
.assertTrue("Reached start or error", LifecycleController.waitForOneOf(
source, LifecycleState.START_OR_ERROR));
Assert.assertEquals("Server is started", LifecycleState.START,
source.getLifecycleState());
// setup a requester, to send a flume OG event
URL url = new URL("http", "0.0.0.0", selectedPort, "/");
Transceiver http = new HttpTransceiver(url);
FlumeOGEventAvroServer client = SpecificRequestor.getClient(
FlumeOGEventAvroServer.class, http);
AvroFlumeOGEvent avroEvent = AvroFlumeOGEvent.newBuilder().setHost("foo")
.setPriority(Priority.INFO).setNanos(0).setTimestamp(1)
.setFields(new HashMap<CharSequence, ByteBuffer>())
.setBody(ByteBuffer.wrap("foo".getBytes())).build();
client.append(avroEvent);
// check if the even has arrived in the channel through OG avro source
Transaction transaction = channel.getTransaction();
transaction.begin();
Event event = channel.take();
Assert.assertNotNull(event);
Assert.assertEquals("Channel contained our event", "foo",
new String(event.getBody()));
transaction.commit();
transaction.close();
source.stop();
Assert.assertTrue("Reached stop or error",
LifecycleController.waitForOneOf(source, LifecycleState.STOP_OR_ERROR));
Assert.assertEquals("Server is stopped", LifecycleState.STOP,
source.getLifecycleState());
}