All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.srotya.minuteman.cluster.Node Maven / Gradle / Ivy

/**
 * Copyright 2017 Ambud Sharma
 * 
 * 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 at
 * 
 * 		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 com.srotya.minuteman.cluster;

import io.grpc.ManagedChannel;
import io.grpc.ManagedChannelBuilder;

public class Node {

	private String nodeKey;
	private String address;
	private int port;
	private transient ManagedChannel inBoundChannel;

	public Node(String nodeKey, String address, int port) {
		super();
		this.nodeKey = nodeKey;
		this.address = address;
		this.port = port;
		inBoundChannel = ManagedChannelBuilder.forAddress(address, port).usePlaintext(true)
				.maxInboundMessageSize(10 * 1024 * 1024).build();
	}
	
	@Override
	public int hashCode() {
		return nodeKey.hashCode();
	}
	
	@Override
	public boolean equals(Object obj) {
		if(obj instanceof Node) {
			return nodeKey.equals(((Node)obj).nodeKey);
		}
		return false;
	}

	/**
	 * @return the nodeKey
	 */
	public String getNodeKey() {
		return nodeKey;
	}

	/**
	 * @param nodeKey
	 *            the nodeKey to set
	 */
	public void setNodeKey(String nodeKey) {
		this.nodeKey = nodeKey;
	}

	/**
	 * @return the address
	 */
	public String getAddress() {
		return address;
	}

	/**
	 * @param address
	 *            the address to set
	 */
	public void setAddress(String address) {
		this.address = address;
	}

	/**
	 * @return the port
	 */
	public int getPort() {
		return port;
	}

	/**
	 * @param port
	 *            the port to set
	 */
	public void setPort(int port) {
		this.port = port;
	}

	/**
	 * @return the inBoundChannel
	 */
	public ManagedChannel getChannel() {
		return inBoundChannel;
	}

	/**
	 * @param inBoundChannel
	 *            the inBoundChannel to set
	 */
	public void setInBoundChannel(ManagedChannel inBoundChannel) {
		this.inBoundChannel = inBoundChannel;
	}

	/* (non-Javadoc)
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString() {
		return "Node [nodeKey=" + nodeKey + ", address=" + address + ", port=" + port + "]";
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy