Package com.tinkerpop.rexster.protocol.msg

Examples of com.tinkerpop.rexster.protocol.msg.ScriptResponseMessage


public class ScriptResponseMessageTemplate extends RexProMessageTemplate<ScriptResponseMessage> {

    @Override
    protected ScriptResponseMessage instantiateMessage() {
        return new ScriptResponseMessage();
    }
View Full Code Here


        return super.messageArraySize() + 2;
    }

    @Override
    protected ScriptResponseMessage instantiateMessage() {
        return new ScriptResponseMessage();
    }
View Full Code Here

        return new ScriptResponseMessage();
    }

    @Override
    protected ScriptResponseMessage readMessageArray(final Unpacker un, final ScriptResponseMessage msg) throws IOException {
        ScriptResponseMessage message = super.readMessageArray(un, msg);
        RexProScriptResult scriptResult = ResultsTemplate.getInstance().read(un, null);
        message.Results.set(scriptResult == null ? null : scriptResult.get());
        message.Bindings = BindingsTemplate.getInstance().read(un, null);
        return message;
    }
View Full Code Here

        long start = System.currentTimeMillis();

        long checkpoint = System.currentTimeMillis();

        try {
            ScriptResponseMessage resultMessage = (ScriptResponseMessage) session.sendRequest(
                    createScriptRequestMessage(session, "g=rexster.getGraph('gratefulgraph');g.V;"), 100);
            resultMessage = (ScriptResponseMessage) session.sendRequest(
                    createScriptRequestMessage(session, "g.E;"), 100);
            System.out.println((checkpoint - start) + ":" + (System.currentTimeMillis() - checkpoint));
View Full Code Here

        long checkpoint = System.currentTimeMillis();

        try {

            ScriptResponseMessage resultMessage = (ScriptResponseMessage) session.sendRequest(
                    createScriptRequestMessage(session, "g=rexster.getGraph('gratefulgraph');g.V;"), 100);

            int counter = 1;
            Iterator itty = ((Iterable) resultMessage.Results).iterator();
            while (itty.hasNext()){
                final Map<String,Object> map = (Map<String, Object>) itty.next();
                final String vId = (String) map.get(Tokens._ID);

                ScriptResponseMessage vertexResultMessage = (ScriptResponseMessage) session.sendRequest(
                        createScriptRequestMessage(session, "g.v(" + vId + ")"), 100);

                System.out.println(vertexResultMessage.Results);
                counter++;
            }
View Full Code Here

     *
     * @param value the value to serialize
     * @return
     */
    private Object serializeAndDeserialize(Object value) throws Exception {
        ScriptResponseMessage msg = new ScriptResponseMessage();
        msg.Results.set(value);
        RexProSerializer serializer = getSerializer();

        byte[] bytes = serializer.serialize(msg, ScriptResponseMessage.class);
        return serializer.deserialize(bytes, ScriptResponseMessage.class);
View Full Code Here

        if (resultMessage == null) {
            throw new IOException(String.format("Message received response timeoutConnection (%s s)", this.timeoutConnection));
        }

        if (resultMessage instanceof ScriptResponseMessage) {
            final ScriptResponseMessage msg = (ScriptResponseMessage) resultMessage;

            // when rexster returns an iterable it's read out of the unpacker as a single object much like a single
            // vertex coming back from rexster.  basically, this is the difference between g.v(1) and g.v(1).map.
            // the latter returns an iterable essentially putting a list inside of the results list here on the
            // client side. the idea here is to normalize all results to a list on the client side, and therefore,
            // iterables like those from g.v(1).map need to be unrolled into the results list.  Prefer this to
            // doing it on the server, because the server should return what is asked of it, in case other clients
            // want to process this differently.
            final List<T> results = new ArrayList<T>();
            if (msg.Results.get() instanceof Iterable) {
                final Iterator<T> itty = ((Iterable) msg.Results.get()).iterator();
                while(itty.hasNext()) {
                    results.add(itty.next());
                }
            } else {
                results.add((T)msg.Results.get());
            }

            return results;

        } else if (resultMessage instanceof ScriptResponseMessage) {
            final ScriptResponseMessage msg = (ScriptResponseMessage) resultMessage;
            final List<T> results = new ArrayList<T>();
            for (String line : (String[]) msg.Results.get()) {
                results.add((T) line);
            }
            return results;
View Full Code Here

        bb.putInt(responseBytes.length);
        bb.put(responseBytes);
    }

    private static ScriptResponseMessage formatForMsgPackChannel(final ScriptRequestMessage specificMessage, final RexProSession session, final Object result) throws Exception {
        final ScriptResponseMessage msgPackScriptResponseMessage = new ScriptResponseMessage();

        if (specificMessage.metaGetInSession()){
            msgPackScriptResponseMessage.Session = specificMessage.Session;
        } else {
            msgPackScriptResponseMessage.setSessionAsUUID(RexProMessage.EMPTY_SESSION);
        }

        msgPackScriptResponseMessage.Request = specificMessage.Request;
        msgPackScriptResponseMessage.Results.set(result);
        if (session != null){
            msgPackScriptResponseMessage.Bindings.putAll(session.getBindings());
        }
        msgPackScriptResponseMessage.validateMetaData();
        return msgPackScriptResponseMessage;
    }
View Full Code Here

        final ConsoleResultConverter converter = new ConsoleResultConverter(new StringWriter());
        return converter.convert(result);
    }

    private static ScriptResponseMessage formatForConsoleChannel(final ScriptRequestMessage specificMessage, final RexProSession session, final Object result) throws Exception {
        final ScriptResponseMessage consoleScriptResponseMessage = new ScriptResponseMessage();

        if (specificMessage.metaGetInSession()){
            consoleScriptResponseMessage.Session = specificMessage.Session;
        } else {
            consoleScriptResponseMessage.setSessionAsUUID(RexProMessage.EMPTY_SESSION);
        }

        consoleScriptResponseMessage.Request = specificMessage.Request;

        final List<String> consoleLines = convertResultToConsoleLines(result);
        consoleScriptResponseMessage.Results.set(consoleLines);
        if (session != null) {
            consoleScriptResponseMessage.Bindings.putAll(session.getBindings());
        }
        consoleScriptResponseMessage.validateMetaData();
        return consoleScriptResponseMessage;
    }
View Full Code Here

            throw new RexProException(((ErrorResponseMessage) inMsg).ErrorMessage);
        } else if (!(inMsg instanceof ScriptResponseMessage)) {
            throw new RexProException("wrong response type");
        }

        final ScriptResponseMessage msg = (ScriptResponseMessage) inMsg;

        return (Map<String, Map<String,String>>) msg.Results.get();
    }
View Full Code Here

TOP

Related Classes of com.tinkerpop.rexster.protocol.msg.ScriptResponseMessage

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.