Package center.system.msg

Examples of center.system.msg.SAMsg$MessageOutputStream


    if (st != null)
      return st;
    Socket s = null;
    try {
      Map<String, Object> prms = cntx.getGroupParams(msg_grp_in);
      SAMsg q = new SAMsg();
      PrmInterface prmi;
      {
        prmi = q.getPrmInterface();
        for(Map.Entry<String, Object> prm : prms.entrySet()) {
          String key = prm.getKey();
          String[] fn = cntx.getFullName(key);
          prmi.setField(fn[1], Strings.getString(cntx.getPrmString(key)));
        }
      }
      s = new Socket(host, port);
      System.out.println("Opened link " + Sockets.getNameLink(s));
     
      InputStream is = s.getInputStream();
      OutputStream os = s.getOutputStream();
      SAMsg in = new SAMsg();
      SAMsg result = new SAMsg();
        int enq = is.read();
        System.out.print("<-- " + toHexString(enq));
        if (enq != SAMsg.ENQ)
          throw new TaskException(State.DONE_ERR, "Incorrect the first signal from host");
        q.sendTo(s.getOutputStream());
        System.out.print("\n-->");
        q.printTo(System.out);

        System.out.println();
        String v;
        for (String n : prmi.getFieldNames()) {
          v = prmi.getField(n);
          System.out.println(n + " = " + v);
        }

        int ch;
        PrmInterface inpi = in.getPrmInterface();
        CloseableOutputStream osc = in.getOutputStream();
        System.out.print("\n<--");
        boolean end = false;
        while (!end && (ch = is.read()) != -1) {
          System.out.print(" ");
          System.out.print(toHexString(ch));
          osc.write(ch);
          if (osc.isClosed()) {
            switch(Integer.parseInt(inpi.getField("type"))) {
            case  SAMsg.STX:
              System.out.println();
              PrmInterface rpi = result.getPrmInterface();
              for (String n : inpi.getFieldNames()) {
                v = inpi.getField(n);
                rpi.setField(n, v);
                System.out.println(n + " = " + v);
              }
              end = true;
              break;
            case  SAMsg.ACK:
              System.out.print("\n<--");
              break;
            case  SAMsg.ENQ:
              System.out.print("\n<--");
              break;
            default:
              System.out.print("\n<--");
              throw new TaskException(State.DONE_ERR, "Incorrect response from host");
            }
            in.reset();
            osc = in.getOutputStream();
          }
        }
       
        os.write(SAMsg.ACK);
        System.out.print("\n--> " + toHexString(SAMsg.ACK));
        os.write(SAMsg.EOT);
        System.out.println("\n--> " + toHexString(SAMsg.EOT));

      PrmInterface rpi = result.getPrmInterface();
      StringList flds = rpi.getFieldNames();
      for (String fld : flds) {
        cntx.setPrmByFullName(msg_grp_out + "/" + fld, rpi.getField(fld), false);
      }
    } catch (UnknownHostException e) {
View Full Code Here


        }
    }

    protected static void writeResponse(final Channel channel, final ManagementRequestHeader header, final Exception error) throws IOException {
        final ManagementResponseHeader response = ManagementResponseHeader.create(header, error);
        final MessageOutputStream output = channel.writeMessage();
        try {
            writeHeader(response, output);
            output.write(ManagementProtocol.RESPONSE_END);
            output.close();
        } finally {
            StreamUtils.safeClose(output);
        }
    }
View Full Code Here

        }
    }

    protected static void writeResponse(final Channel channel, final ManagementRequestHeader header, final byte param) throws IOException {
        final ManagementResponseHeader response = ManagementResponseHeader.create(header);
        final MessageOutputStream output = channel.writeMessage();
        try {
            writeHeader(response, output);
            output.write(param);
            output.write(ManagementProtocol.RESPONSE_END);
            output.close();
        } finally {
            StreamUtils.safeClose(output);
        }
    }
View Full Code Here

                    getExecutor().execute(runner);
                }

                @Override
                public FlushableDataOutput writeMessage(final ManagementProtocolHeader header) throws IOException {
                    final MessageOutputStream os = channel.writeMessage();
                    return writeHeader(header, os);
                }
            });

        } catch (Exception e) {
View Full Code Here

                    getExecutor().execute(runner);
                }

                @Override
                public FlushableDataOutput writeMessage(final ManagementProtocolHeader header) throws IOException {
                    final MessageOutputStream os = channel.writeMessage();
                    return writeHeader(header, os);
                }

            });
        } catch (Exception e) {
View Full Code Here

     * @param error the error
     * @throws IOException
     */
    protected static void writeErrorResponse(final Channel channel, final ManagementRequestHeader header, final Exception error) throws IOException {
        final ManagementResponseHeader response = ManagementResponseHeader.create(header, error);
        final MessageOutputStream output = channel.writeMessage();
        try {
            writeHeader(response, output);
            output.close();
        } finally {
            StreamUtils.safeClose(output);
        }
    }
View Full Code Here

     * @param header the protocol header
     * @throws IOException for any error
     */
    protected static void handlePing(final Channel channel, final ManagementProtocolHeader header) throws IOException {
        final ManagementProtocolHeader response = new ManagementPongHeader(header.getVersion());
        final MessageOutputStream output = channel.writeMessage();
        try {
            writeHeader(response, output);
            output.close();
        } finally {
            StreamUtils.safeClose(output);
        }
    }
View Full Code Here

    protected void writeException(final ChannelAssociation channelAssociation, final MarshallerFactory marshallerFactory,
                                  final short invocationId, final Throwable t,
                                  final Map<String, Object> attachments) throws IOException {
        final DataOutputStream outputStream;
        final MessageOutputStream messageOutputStream;
        try {
            messageOutputStream = channelAssociation.acquireChannelMessageOutputStream();
        } catch (Exception e) {
            throw EjbMessages.MESSAGES.failedToOpenMessageOutputStream(e);
        }
View Full Code Here

        }
    }

    protected void writeInvocationFailure(final ChannelAssociation channelAssociation, final byte messageHeader, final short invocationId, final String failureMessage) throws IOException {
        final DataOutputStream dataOutputStream;
        final MessageOutputStream messageOutputStream;
        try {
            messageOutputStream = channelAssociation.acquireChannelMessageOutputStream();
        } catch (Exception e) {
            throw EjbMessages.MESSAGES.failedToOpenMessageOutputStream(e);
        }
View Full Code Here

        return null;
    }

    private void writeMethodInvocationResponse(final ChannelAssociation channelAssociation, final short invocationId, final Object result, final Map<String, Object> attachments) throws IOException {
        final DataOutputStream outputStream;
        final MessageOutputStream messageOutputStream;
        try {
            messageOutputStream = channelAssociation.acquireChannelMessageOutputStream();
        } catch (Throwable e) {
            throw EjbMessages.MESSAGES.failedToOpenMessageOutputStream(e);
        }
View Full Code Here

TOP

Related Classes of center.system.msg.SAMsg$MessageOutputStream

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.