Package be.bagofwords.util

Examples of be.bagofwords.util.WrappedSocketConnection


    }

    @Override
    public InputStream createInputStream() {
        try {
            WrappedSocketConnection connection = new WrappedSocketConnection(host, port);
            connection.writeByte((byte) RemoteFileServer.Action.INPUT_STREAM.ordinal());
            connection.writeString(relPath.getPath());
            connection.flush();
            long answer = connection.readLong();
            if (answer == BaseServer.LONG_OK) {
                return connection.getIs();
            } else {
                String message = connection.readString();
                throw new RuntimeException("Received unexpected response while creating input stream to " + host + ":" + port + " " + message);
            }
        } catch (IOException exp) {
            throw new RuntimeException("Received exception while creating input stream to " + host + ":" + port, exp);
        }
View Full Code Here


    @Override
    protected void runInt() throws Exception {
        while (!serverSocket.isClosed() && !isTerminateRequested()) {
            try {
                WrappedSocketConnection connection = new WrappedSocketConnection(serverSocket.accept());
                SocketRequestHandler handler = createSocketRequestHandler(connection);
                if (handler != null) {
                    synchronized (runningRequestHandlers) {
                        runningRequestHandlers.add(handler);
                    }
View Full Code Here

        }
    }

    private void valuesChangedForInterface(String interfaceName, long[] keys) {
        for (int i = 0; i < listenToChangesConnections.size(); i++) {
            WrappedSocketConnection connection = listenToChangesConnections.get(i);
            try {
                connection.writeString(interfaceName);
                connection.writeInt(keys.length);
                for (Long key : keys) {
                    connection.writeLong(key);
                }
                connection.flush();
                long response = connection.readLong();
                if (response != LONG_OK) {
                    throw new RuntimeException("Unexpected response " + response + " from " + connection.getInetAddress());
                }
            } catch (IOException exp) {
                IOUtils.closeQuietly(connection);
                listenToChangesConnections.remove(i--);
            }
View Full Code Here

        private WrappedSocketConnection connection;

        public ChangedValueListenerThread() throws IOException {
            super("ChangedValueListener", false);
            connection = new WrappedSocketConnection(host, port);
        }
View Full Code Here

    }

    @Override
    public OutputStream createOutputStream() {
        try {
            WrappedSocketConnection connection = new WrappedSocketConnection(host, 1220);
            connection.writeByte((byte) RemoteFileServer.Action.OUTPUT_STREAM.ordinal());
            connection.writeString(relPath.getPath());
            connection.flush();
            long answer = connection.readLong();
            if (answer == BaseServer.LONG_OK) {
                return connection.getOs();
            } else {
                String message = connection.readString();
                throw new RuntimeException("Received unexpected response while creating output stream to " + host + ":" + port + " " + message);
            }
        } catch (IOException exp) {
            throw new RuntimeException("Received exception while creating output stream to " + host + ":" + port, exp);
        }
View Full Code Here

        }
    }

    @Override
    public boolean exists() {
        WrappedSocketConnection connection = null;
        try {
            connection = new WrappedSocketConnection(host, 1220);
            connection.writeByte((byte) RemoteFileServer.Action.EXISTS.ordinal());
            connection.writeString(relPath.getPath());
            connection.flush();
            return connection.readBoolean();
        } catch (IOException exp) {
            throw new RuntimeException("Received exception while querying exists to " + host + ":" + port, exp);
        } finally {
            IOUtils.closeQuietly(connection);
        }
View Full Code Here

TOP

Related Classes of be.bagofwords.util.WrappedSocketConnection

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.