当前位置: 首页>>代码示例>>Java>>正文


Java SpecificRequestor.getClient方法代码示例

本文整理汇总了Java中org.apache.avro.ipc.specific.SpecificRequestor.getClient方法的典型用法代码示例。如果您正苦于以下问题:Java SpecificRequestor.getClient方法的具体用法?Java SpecificRequestor.getClient怎么用?Java SpecificRequestor.getClient使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.avro.ipc.specific.SpecificRequestor的用法示例。


在下文中一共展示了SpecificRequestor.getClient方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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

示例6: 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

示例7: 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

示例8: 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

示例9: 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

示例10: 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

示例11: 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.getClient方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。