Skip to content
This repository has been archived by the owner on Jun 12, 2023. It is now read-only.

Commit

Permalink
1、整理成一个cluster port
Browse files Browse the repository at this point in the history
2、tnsrpc client采用cluster port+1
  • Loading branch information
jerry committed May 11, 2016
1 parent d44834c commit 896abe7
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 59 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
import org.slf4j.LoggerFactory;

import com.qibaike.thriftnameserver.conf.Config;
import com.qibaike.thriftnameserver.rpc.clusterConstants;
import com.qibaike.thriftnameserver.rpc.tnsrpcConstants;
import com.qibaike.thriftnameserver.rpc.structConstants;

public class ThriftNameServer {
public static void main(String[] args) {
Expand All @@ -18,15 +17,14 @@ public static void main(String[] args) {
* cluster rpc
*/
ClusterRpcServer clusterRpcServer = new ClusterRpcServer();
clusterRpcServer.start(host, clusterConstants.PORT);
clusterRpcServer.start(host, structConstants.PORT);

/**
* tns rpc
*/
TNSRpcServer tnsRpcServer = new TNSRpcServer();
tnsRpcServer.start(host, tnsrpcConstants.PORT);


tnsRpcServer.start(host, structConstants.PORT + 1);

SNodeManagerMBeanServer sNodeManagerMBeanServer = new SNodeManagerMBeanServer();
sNodeManagerMBeanServer.start();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import com.qibaike.thriftnameserver.rpc.Cluster;
import com.qibaike.thriftnameserver.rpc.State;
import com.qibaike.thriftnameserver.rpc.TCNode;
import com.qibaike.thriftnameserver.rpc.clusterConstants;
import com.qibaike.thriftnameserver.rpc.structConstants;

public class CNodeManager implements CNodeManagerMBean {

Expand All @@ -30,7 +30,7 @@ private CNodeManager() {

TCNode me = new TCNode();
me.setHost(Config.HOSTNAME);
me.setPort(clusterConstants.PORT);
me.setPort(structConstants.PORT);
me.setId(myId);
me.setState(State.Joining);
me.setTimestamp(System.currentTimeMillis());
Expand Down Expand Up @@ -124,7 +124,7 @@ private TCNode getOne(Long id) {
@Override
@Loggable
public String meet(String host) {
TSocket transport = new TSocket(host, clusterConstants.PORT, 2000);
TSocket transport = new TSocket(host, structConstants.PORT, 2000);
TProtocol protocol = new TBinaryProtocol(transport);
Cluster.Client client = new Cluster.Client(protocol);
try {
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/com/qibaike/thriftnameserver/conf/Config.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package com.qibaike.thriftnameserver.conf;

import com.qibaike.thriftnameserver.rpc.clusterConstants;
import com.qibaike.thriftnameserver.rpc.structConstants;

public class Config {
public static final String HOSTNAME = System.getProperty("hostname", "localhost");

public static final Long TNSID = (long) (HOSTNAME+clusterConstants.PORT).hashCode();
public static final Long TNSID = (long) (HOSTNAME + structConstants.PORT).hashCode();

public static final Long serviceRemoveSeconds = 60L;
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

This file was deleted.

2 changes: 0 additions & 2 deletions thrift/cluster.thrift
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ namespace java com.qibaike.thriftnameserver.rpc

include "struct.thrift"

const i32 PORT = 8700

service Cluster {

/**
Expand Down
2 changes: 2 additions & 0 deletions thrift/struct.thrift
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
namespace java com.qibaike.thriftnameserver.rpc

const i32 PORT = 8700

enum State {
UP = 1,
DOWN = 2,
Expand Down
2 changes: 0 additions & 2 deletions thrift/tnsrpc.thrift
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ namespace java com.qibaike.thriftnameserver.rpc

include "struct.thrift"

const i32 PORT = 8701

service TNSRpc {

/**
Expand Down

0 comments on commit 896abe7

Please sign in to comment.