• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java SpecificRequestor类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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();
        }

    }
 
开发者ID:glzbcrt,项目名称:avro,代码行数:27,代码来源:ProtocolServer01.java


示例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 + "]");
    }
}
 
开发者ID:apache,项目名称:oodt,代码行数:20,代码来源:AvroFileManagerClient.java


示例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();
}
 
开发者ID:gauravrmazra,项目名称:gauravbytes,代码行数:28,代码来源:EmailClientServer.java


示例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());
}
 
开发者ID:lrtdc,项目名称:book_ldrtc,代码行数:21,代码来源:MemberServerConsumer.java


示例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);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:15,代码来源:AvroHttpConsumerTest.java


示例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);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:15,代码来源:AvroNettyConsumerTest.java


示例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();        
}
 
开发者ID:duchien85,项目名称:netty-cookbook,代码行数:16,代码来源:ClientAvroRPC.java


示例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;
}
 
开发者ID:bionimbuz,项目名称:Bionimbuz,代码行数:19,代码来源:AvroClient.java


示例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;
}
 
开发者ID:bionimbuz,项目名称:Bionimbuz,代码行数:18,代码来源:AvroClient.java


示例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();
    }

}
 
开发者ID:apache,项目名称:oodt,代码行数:12,代码来源:AvroRpcWorkflowManagerClient.java


示例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();
    }

}
 
开发者ID:apache,项目名称:oodt,代码行数:12,代码来源:AvroRpcWorkflowManagerClient.java


示例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());
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:66,代码来源:TestAvroSource.java


示例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());
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:59,代码来源:TestLegacyAvroSource.java



注:本文中的org.apache.avro.ipc.specific.SpecificRequestor类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Setter类代码示例发布时间:2022-05-21
下一篇:
Java NegotiationType类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap