Commit 486980f3 authored by chiaming2000's avatar chiaming2000
Browse files

Remove V1 protocol configuration support for client/simulator.

parent 53284862
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -76,7 +76,7 @@ public class ClientProxy {
    private final Map<Long, Key> hmacKeyMap = new HashMap<Long, Key>();

    // use protocol v2
    private boolean useV2Protocol = false;
    private boolean useV2Protocol = true;

    /**
     * Construct a new instance of client proxy
@@ -92,7 +92,7 @@ public class ClientProxy {
        this.config = config;

        // set to true if v2 protocol is used
        this.useV2Protocol = config.getUseV2Protocol();
        this.useV2Protocol = true;

        // get user principal from client config
        user = config.getUserId();
+8 −27
Original line number Diff line number Diff line
@@ -13,10 +13,7 @@ package com.seagate.kinetic.client.io.provider.nio.ssl;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.protobuf.ProtobufDecoder;
import io.netty.handler.codec.protobuf.ProtobufEncoder;
import io.netty.handler.codec.protobuf.ProtobufVarint32FrameDecoder;
import io.netty.handler.codec.protobuf.ProtobufVarint32LengthFieldPrepender;

import io.netty.handler.ssl.SslHandler;

import java.util.logging.Logger;
@@ -27,7 +24,7 @@ import com.seagate.kinetic.client.io.provider.spi.ClientMessageService;
import com.seagate.kinetic.common.lib.TlsUtil;
import com.seagate.kinetic.common.protocol.codec.KineticDecoder;
import com.seagate.kinetic.common.protocol.codec.KineticEncoder;
import com.seagate.kinetic.proto.Kinetic;
//import com.seagate.kinetic.proto.Kinetic;

/**
 *
@@ -40,14 +37,10 @@ ChannelInitializer<SocketChannel> {
	private static final Logger logger = Logger
			.getLogger(SslChannelInitializer.class.getName());

	private boolean useV2Protocol = false;

	private ClientMessageService mservice = null;

	public SslChannelInitializer(ClientMessageService mservice) {
		this.mservice = mservice;
		this.useV2Protocol = this.mservice.getConfiguration()
				.getUseV2Protocol();
	}

	@Override
@@ -75,25 +68,13 @@ ChannelInitializer<SocketChannel> {
		// add ssl handler
		pipeline.addLast("ssl", new SslHandler(engine));

		if (this.useV2Protocol) {
		// decoder
		pipeline.addLast("decoder", new KineticDecoder());
		// encoder
		pipeline.addLast("encoder", new KineticEncoder());
		} else {

			pipeline.addLast("frameDecoder", new ProtobufVarint32FrameDecoder());
			pipeline.addLast("protobufDecoder",
					new ProtobufDecoder(Kinetic.Message.getDefaultInstance()));

			pipeline.addLast("frameEncoder",
					new ProtobufVarint32LengthFieldPrepender());
			pipeline.addLast("protobufEncoder", new ProtobufEncoder());
		}
		
		pipeline.addLast("handler", new SslMessageServiceHandler(mservice));

		logger.info("ssl channel initialized, use v2 protocol = "
				+ this.useV2Protocol);
		logger.info("ssl channel initialized ... ");
	}
}
+11 −25
Original line number Diff line number Diff line
@@ -13,17 +13,17 @@ package com.seagate.kinetic.client.io.provider.nio.tcp;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.protobuf.ProtobufDecoder;
import io.netty.handler.codec.protobuf.ProtobufEncoder;
import io.netty.handler.codec.protobuf.ProtobufVarint32FrameDecoder;
import io.netty.handler.codec.protobuf.ProtobufVarint32LengthFieldPrepender;
//import io.netty.handler.codec.protobuf.ProtobufDecoder;
//import io.netty.handler.codec.protobuf.ProtobufEncoder;
//import io.netty.handler.codec.protobuf.ProtobufVarint32FrameDecoder;
//import io.netty.handler.codec.protobuf.ProtobufVarint32LengthFieldPrepender;

import java.util.logging.Logger;

import com.seagate.kinetic.client.io.provider.spi.ClientMessageService;
import com.seagate.kinetic.common.protocol.codec.KineticDecoder;
import com.seagate.kinetic.common.protocol.codec.KineticEncoder;
import com.seagate.kinetic.proto.Kinetic;
//import com.seagate.kinetic.proto.Kinetic;

/**
 *
@@ -36,14 +36,10 @@ ChannelInitializer<SocketChannel> {
	private final Logger logger = Logger
			.getLogger(NioChannelInitializer.class.getName());

	private boolean useV2Protocol = false;

	private ClientMessageService mservice = null;

	public NioChannelInitializer(ClientMessageService mservice) {
		this.mservice = mservice;
		this.useV2Protocol = mservice.getConfiguration()
				.getUseV2Protocol();
	}

	@Override
@@ -58,23 +54,13 @@ ChannelInitializer<SocketChannel> {

		ChannelPipeline p = ch.pipeline();

		if (this.useV2Protocol) {
		// decoder
		p.addLast("decoder", new KineticDecoder());
		// encoder
		p.addLast("encoder", new KineticEncoder());
		} else {
			p.addLast("frameDecoder", new ProtobufVarint32FrameDecoder());
			p.addLast("protobufDecoder",
					new ProtobufDecoder(Kinetic.Message.getDefaultInstance()));

			p.addLast("frameEncoder", new ProtobufVarint32LengthFieldPrepender());
			p.addLast("protobufEncoder", new ProtobufEncoder());
		}
		 
		p.addLast("handler", new NioMessageServiceHandler(mservice));

		logger.info("nio channel initialized., using v2 protocol="
				+ this.useV2Protocol);
		logger.info("nio channel initialized ...");
	}
}
+2 −2
Original line number Diff line number Diff line
@@ -50,7 +50,7 @@ public class TcpTransportProvider implements ClientTransportProvider, Runnable {
	private final Logger logger = Logger
			.getLogger(TcpTransportProvider.class.getName());

	private boolean useV2Protocol = false;
	private boolean useV2Protocol = true;

	// input socket read thread
	private Thread myThread = null;
@@ -85,7 +85,7 @@ public class TcpTransportProvider implements ClientTransportProvider, Runnable {

		ClientConfiguration config = mservice.getConfiguration();

		this.useV2Protocol = config.getUseV2Protocol();
		this.useV2Protocol = true;

		this.mservice = mservice;

+7 −11
Original line number Diff line number Diff line
@@ -66,10 +66,6 @@ public class ClientConfiguration extends Properties {
	 */
	private volatile boolean useSsl = Boolean.getBoolean("kinetic.io.ssl");

	// private volatile boolean useV2Protocol = Boolean
	// .getBoolean("kinetic.protocol.v2");

	private volatile boolean useV2Protocol = true;
	
	/**
	 * ssl default port if useSsl is set to true.
@@ -419,9 +415,9 @@ public class ClientConfiguration extends Properties {
	 * 
	 * @return true if v2 protocol is used.
	 */
	public boolean getUseV2Protocol() {
		return this.useV2Protocol;
	}
	//public boolean getUseV2Protocol() {
	//	return this.useV2Protocol;
	//}

	/**
	 * Set if v2 protocol is to be used to communicate with the simulator/drive.
@@ -429,8 +425,8 @@ public class ClientConfiguration extends Properties {
	 * @param flag
	 *            true if v2 protocol is used.
	 */
	public void setUseV2Protocol(boolean flag) {
		this.useV2Protocol = flag;
	}
	//public void setUseV2Protocol(boolean flag) {
	//	this.useV2Protocol = flag;
	//}

}
Loading