Package org.apache.flink.core.io

Examples of org.apache.flink.core.io.IOReadableWritable


    if (clazz == null) {
      fail("Cannot find class with name " + className);
    }

    IOReadableWritable copy = null;
    try {
      copy = clazz.newInstance();
    } catch (InstantiationException e) {
      fail(e.getMessage());
    } catch (IllegalAccessException e) {
      fail(e.getMessage());
    }

    if (copy == null) {
      fail("Copy of object of type " + className + " is null");
    }

    final ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
    final DataInputStream dis = new DataInputStream(bais);

    try {
      copy.read(new InputViewDataInputStreamWrapper(dis));
    } catch (IOException e) {
      fail(e.getMessage());
    }

    return copy;
View Full Code Here


    private void processData() throws IOException, InterruptedException {
      DataInputStream dis = new DataInputStream(new ByteArrayInputStream(data.array()));
      int id = dis.readInt(); // try to read an id


      IOReadableWritable invocation = newInstance(invocationClass); // read param
      invocation.read(new InputViewDataInputStreamWrapper(dis));

      Call call = new Call(id, invocation, this);
      callQueue.put(call); // queue the call; maybe blocked here
    }
View Full Code Here

        try {
          final Call call = callQueue.take(); // pop the queue; maybe blocked here

          String errorClass = null;
          String error = null;
          IOReadableWritable value = null;

          CurCall.set(call);

          value = call(call.connection.protocol, call.param, call.timestamp);
          CurCall.set(null);
View Full Code Here

        final Call call = calls.remove(id);

        final int state = in.readInt(); // read call status
        if (state == Status.SUCCESS.state) {
          IOReadableWritable value = null;
          boolean isNotNull = in.readBoolean();
          if (isNotNull) {
            final String returnClassName = StringRecord.readString(in);
            Class<? extends IOReadableWritable> c = null;
            try {
              c = ClassUtils.getRecordByName(returnClassName);
            } catch (ClassNotFoundException e) {
              LOG.error("Could not find class " + returnClassName + ".", e);
            }
            try {
              value = c.newInstance();
            } catch (InstantiationException e) {
              LOG.error("Could not instantiate object of class " + c.getCanonicalName() + ".", e);
            } catch (IllegalAccessException e) {
              LOG.error("Error instantiating object of class " + c.getCanonicalName() + ".", e);
            }
            try {
              value.read(new InputViewDataInputStreamWrapper(in)); // read value
            } catch(Throwable e) {
              LOG.error("Exception while receiving an RPC call", e);
            }
          }
          call.setValue(value);
View Full Code Here

          throw new IOException(e);
        }

        // See if parameter is null
        if (in.readBoolean()) {
          IOReadableWritable value;
          try {
            final String parameterClassName = StringRecord.readString(in);
            final Class<? extends IOReadableWritable> parameterClass =
                (Class<? extends IOReadableWritable>) ClassUtils.resolveClassPrimitiveAware(parameterClassName);
           
            value = parameterClass.newInstance();
            parameters[i] = value;
          }
          catch (Exception e) {
            throw new IOException(e);
          }
          // Object will do everything else on its own
          value.read(in);
        } else {
          parameters[i] = null;
        }
      }
    }
View Full Code Here

    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
      Invocation invocation = new Invocation(method, args);
      invocation.doTypeConversion();
     
      IOReadableWritable retValue = this.client.call(invocation, this.address, method.getDeclaringClass());
     
      if (retValue == null) {
        return null;
      }
      else if (ClassUtils.isPrimitiveOrBoxedOrString(method.getReturnType())) {
View Full Code Here

TOP

Related Classes of org.apache.flink.core.io.IOReadableWritable

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.