/*
 * Copyright 2009-2010 by The Regents of the University of California
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * you may obtain a copy of the License from
 * 
 *     http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package edu.uci.ics.hyracks.client.net;

import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.SocketAddress;

import edu.uci.ics.hyracks.comm.channels.IChannelConnectionFactory;
import edu.uci.ics.hyracks.net.exceptions.NetException;
import edu.uci.ics.hyracks.net.protocols.muxdemux.ChannelControlBlock;
import edu.uci.ics.hyracks.net.protocols.muxdemux.MultiplexedConnection;
import edu.uci.ics.hyracks.net.protocols.muxdemux.MuxDemux;
import edu.uci.ics.hyracks.net.protocols.muxdemux.MuxDemuxPerformanceCounters;

public class ClientNetworkManager implements IChannelConnectionFactory {
    private static final int MAX_CONNECTION_ATTEMPTS = 5;

    private final MuxDemux md;

    public ClientNetworkManager(int nThreads)
            throws IOException {
        md = new MuxDemux(nThreads, MAX_CONNECTION_ATTEMPTS);
    }

    public void start() throws IOException {
        md.start();
    }

    public void stop() {

    }

    public ChannelControlBlock connect(SocketAddress remoteAddress) throws InterruptedException, NetException {
        MultiplexedConnection mConn = md.connect((InetSocketAddress) remoteAddress);
        return mConn.openChannel();
    }

    public MuxDemuxPerformanceCounters getPerformanceCounters() {
        return md.getPerformanceCounters();
    }
}
Implement a network manager for the dataset clients to talk to the result distributing nodes.
Implement a network manager for the dataset clients to talk to the result distributing nodes.

git-svn-id: 45400e483b316c70cab0969c275555ef2720fd29@2511 123451ca-8445-de46-9d55-352943316053
