コード例 #1
0
 public void onError_async(
     String errcode,
     String errmsg,
     ITerminal_AsyncCallBack async,
     HashMap<String, String> props,
     Object cookie)
     throws RpcException {
   boolean r_7 = false;
   RpcMessage m_8 = new RpcMessage(RpcMessage.CALL | RpcMessage.ASYNC);
   m_8.ifidx = 0;
   m_8.opidx = 2;
   m_8.paramsize = 2;
   m_8.extra.setProperties(props);
   m_8.cookie = cookie;
   try {
     ByteArrayOutputStream bos_9 = new ByteArrayOutputStream();
     DataOutputStream dos_10 = new DataOutputStream(bos_9);
     byte[] sb_11 = errcode.getBytes();
     dos_10.writeInt(sb_11.length);
     dos_10.write(sb_11, 0, sb_11.length);
     byte[] sb_12 = errmsg.getBytes();
     dos_10.writeInt(sb_12.length);
     dos_10.write(sb_12, 0, sb_12.length);
     m_8.paramstream = bos_9.toByteArray();
     m_8.prx = this;
     m_8.async = async;
   } catch (Exception e) {
     throw new RpcException(RpcConsts.RPCERROR_DATADIRTY, e.toString());
   }
   r_7 = this.conn.sendMessage(m_8);
   if (!r_7) {
     throw new RpcException(RpcConsts.RPCERROR_SENDFAILED);
   }
 }
コード例 #2
0
 public void onError_oneway(String errcode, String errmsg, HashMap<String, String> props)
     throws RpcException {
   boolean r_1 = false;
   RpcMessage m_2 = new RpcMessage(RpcMessage.CALL | RpcMessage.ONEWAY);
   m_2.ifidx = 0;
   m_2.opidx = 2;
   m_2.paramsize = 2;
   m_2.extra.setProperties(props);
   try {
     ByteArrayOutputStream bos_3 = new ByteArrayOutputStream();
     DataOutputStream dos_4 = new DataOutputStream(bos_3);
     byte[] sb_5 = errcode.getBytes();
     dos_4.writeInt(sb_5.length);
     dos_4.write(sb_5, 0, sb_5.length);
     byte[] sb_6 = errmsg.getBytes();
     dos_4.writeInt(sb_6.length);
     dos_4.write(sb_6, 0, sb_6.length);
     m_2.paramstream = bos_3.toByteArray();
     m_2.prx = this;
   } catch (Exception e) {
     throw new RpcException(RpcConsts.RPCERROR_DATADIRTY, e.toString());
   }
   r_1 = this.conn.sendMessage(m_2);
   if (!r_1) {
     throw new RpcException(RpcConsts.RPCERROR_SENDFAILED);
   }
 }
コード例 #3
0
ファイル: BaseDataBuffer.java プロジェクト: evaleen/nd4j
 protected void write(DataOutputStream out) throws IOException {
   out.writeUTF(allocationMode.name());
   out.writeInt(length());
   out.writeUTF(dataType().name());
   if (dataType() == Type.DOUBLE) {
     for (int i = 0; i < length(); i++) out.writeDouble(getDouble(i));
   } else {
     for (int i = 0; i < length(); i++) out.writeFloat(getFloat(i));
   }
 }
コード例 #4
0
ファイル: Error_t.java プロジェクト: adoggie/Koala-Messaging
 // return xml string
 public boolean marshall(DataOutputStream d) {
   try {
     d.writeByte(succ.booleanValue() ? 1 : 0);
     d.writeInt(code);
     byte[] sb_1 = msg.getBytes();
     d.writeInt(sb_1.length);
     d.write(sb_1, 0, sb_1.length);
   } catch (Exception e) {
     return false;
   }
   return true;
 }
コード例 #5
0
 // timeout - msec ,  0 means waiting infinitely
 public void onError(String errcode, String errmsg, int timeout, HashMap<String, String> props)
     throws RpcException {
   boolean r_1 = false;
   RpcMessage m_2 = new RpcMessage(RpcMessage.CALL);
   m_2.ifidx = 0;
   m_2.opidx = 2;
   m_2.paramsize = 2;
   m_2.extra.setProperties(props);
   try {
     ByteArrayOutputStream bos_3 = new ByteArrayOutputStream();
     DataOutputStream dos_4 = new DataOutputStream(bos_3);
     byte[] sb_5 = errcode.getBytes();
     dos_4.writeInt(sb_5.length);
     dos_4.write(sb_5, 0, sb_5.length);
     byte[] sb_6 = errmsg.getBytes();
     dos_4.writeInt(sb_6.length);
     dos_4.write(sb_6, 0, sb_6.length);
     m_2.paramstream = bos_3.toByteArray();
     m_2.prx = this;
   } catch (Exception e) {
     throw new RpcException(RpcConsts.RPCERROR_DATADIRTY, e.toString());
   }
   synchronized (m_2) {
     r_1 = this.conn.sendMessage(m_2);
     if (!r_1) {
       throw new RpcException(RpcConsts.RPCERROR_SENDFAILED);
     }
     try {
       if (timeout > 0) m_2.wait(timeout);
       else m_2.wait();
     } catch (Exception e) {
       throw new RpcException(RpcConsts.RPCERROR_INTERNAL_EXCEPTION, e.getMessage());
     }
   }
   if (m_2.errcode != RpcConsts.RPCERROR_SUCC) {
     throw new RpcException(m_2.errcode);
   }
   if (m_2.result == null) {
     throw new RpcException(RpcConsts.RPCERROR_TIMEOUT);
   }
 }
コード例 #6
0
ファイル: BaseDataBuffer.java プロジェクト: evaleen/nd4j
  @Override
  public byte[] asBytes() {
    if (allocationMode == AllocationMode.HEAP) {
      ByteArrayOutputStream bos = new ByteArrayOutputStream(getElementSize() * length());
      DataOutputStream dos = new DataOutputStream(bos);

      if (dataType() == Type.DOUBLE) {
        if (doubleData == null) throw new IllegalStateException("Double array is null!");

        try {
          for (int i = 0; i < doubleData.length; i++) dos.writeDouble(doubleData[i]);
        } catch (IOException e) {
          throw new RuntimeException(e);
        }

      } else {
        if (floatData == null) throw new IllegalStateException("Double array is null!");

        try {
          for (int i = 0; i < floatData.length; i++) dos.writeFloat(floatData[i]);
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }

      return bos.toByteArray();

    } else {
      ByteArrayOutputStream bos = new ByteArrayOutputStream();
      DataOutputStream dos = new DataOutputStream(bos);
      if (dataType() == Type.DOUBLE) {
        for (int i = 0; i < length(); i++) {
          try {
            dos.writeDouble(getDouble(i));
          } catch (IOException e) {
            e.printStackTrace();
          }
        }
      } else {
        for (int i = 0; i < length(); i++) {
          try {
            dos.writeFloat(getFloat(i));
          } catch (IOException e) {
            e.printStackTrace();
          }
        }
      }
      return bos.toByteArray();
    }
  }