Exemple #1
0
  @Test
  public void testVersion_from0to0() throws Exception {
    serviceA.registerHandler(
        "/version",
        new BaseTransportRequestHandler<Version0Request>() {
          @Override
          public Version0Request newInstance() {
            return new Version0Request();
          }

          @Override
          public void messageReceived(Version0Request request, TransportChannel channel)
              throws Exception {
            assertThat(request.value1, equalTo(1));
            Version0Response response = new Version0Response();
            response.value1 = 1;
            channel.sendResponse(response);
          }

          @Override
          public String executor() {
            return ThreadPool.Names.SAME;
          }
        });

    Version0Request version0Request = new Version0Request();
    version0Request.value1 = 1;
    Version0Response version0Response =
        serviceA
            .submitRequest(
                nodeA,
                "/version",
                version0Request,
                new BaseTransportResponseHandler<Version0Response>() {
                  @Override
                  public Version0Response newInstance() {
                    return new Version0Response();
                  }

                  @Override
                  public void handleResponse(Version0Response response) {
                    assertThat(response.value1, equalTo(1));
                  }

                  @Override
                  public void handleException(TransportException exp) {
                    exp.printStackTrace();
                    assert false;
                  }

                  @Override
                  public String executor() {
                    return ThreadPool.Names.SAME;
                  }
                })
            .txGet();

    assertThat(version0Response.value1, equalTo(1));
  }
Exemple #2
0
 @Override
 public void writeTo(StreamOutput out) throws IOException {
   super.writeTo(out);
   if (out.getVersion().onOrAfter(version1)) {
     out.writeInt(value2);
   }
 }
Exemple #3
0
 @Override
 public void readFrom(StreamInput in) throws IOException {
   super.readFrom(in);
   if (in.getVersion().onOrAfter(version1)) {
     value2 = in.readInt();
   }
 }