|
@@ -69,17 +69,17 @@ import javax.security.sasl.SaslException;
|
|
*/
|
|
*/
|
|
public class ZooKeeperServer implements SessionExpirer, ServerStats.Provider {
|
|
public class ZooKeeperServer implements SessionExpirer, ServerStats.Provider {
|
|
protected static final Logger LOG;
|
|
protected static final Logger LOG;
|
|
-
|
|
|
|
|
|
+
|
|
static {
|
|
static {
|
|
LOG = LoggerFactory.getLogger(ZooKeeperServer.class);
|
|
LOG = LoggerFactory.getLogger(ZooKeeperServer.class);
|
|
-
|
|
|
|
|
|
+
|
|
Environment.logEnv("Server environment:", LOG);
|
|
Environment.logEnv("Server environment:", LOG);
|
|
}
|
|
}
|
|
|
|
|
|
protected ZooKeeperServerBean jmxServerBean;
|
|
protected ZooKeeperServerBean jmxServerBean;
|
|
protected DataTreeBean jmxDataTreeBean;
|
|
protected DataTreeBean jmxDataTreeBean;
|
|
|
|
|
|
-
|
|
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* The server delegates loading of the tree to an instance of the interface
|
|
* The server delegates loading of the tree to an instance of the interface
|
|
*/
|
|
*/
|
|
@@ -119,7 +119,7 @@ public class ZooKeeperServer implements SessionExpirer, ServerStats.Provider {
|
|
// this data structure must be accessed under the outstandingChanges lock
|
|
// this data structure must be accessed under the outstandingChanges lock
|
|
final HashMap<String, ChangeRecord> outstandingChangesForPath =
|
|
final HashMap<String, ChangeRecord> outstandingChangesForPath =
|
|
new HashMap<String, ChangeRecord>();
|
|
new HashMap<String, ChangeRecord>();
|
|
-
|
|
|
|
|
|
+
|
|
private ServerCnxnFactory serverCnxnFactory;
|
|
private ServerCnxnFactory serverCnxnFactory;
|
|
|
|
|
|
private final ServerStats serverStats;
|
|
private final ServerStats serverStats;
|
|
@@ -127,22 +127,22 @@ public class ZooKeeperServer implements SessionExpirer, ServerStats.Provider {
|
|
void removeCnxn(ServerCnxn cnxn) {
|
|
void removeCnxn(ServerCnxn cnxn) {
|
|
zkDb.removeCnxn(cnxn);
|
|
zkDb.removeCnxn(cnxn);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* Creates a ZooKeeperServer instance. Nothing is setup, use the setX
|
|
* Creates a ZooKeeperServer instance. Nothing is setup, use the setX
|
|
- * methods to prepare the instance (eg datadir, datalogdir, ticktime,
|
|
|
|
|
|
+ * methods to prepare the instance (eg datadir, datalogdir, ticktime,
|
|
* builder, etc...)
|
|
* builder, etc...)
|
|
- *
|
|
|
|
|
|
+ *
|
|
* @throws IOException
|
|
* @throws IOException
|
|
*/
|
|
*/
|
|
public ZooKeeperServer() {
|
|
public ZooKeeperServer() {
|
|
serverStats = new ServerStats(this);
|
|
serverStats = new ServerStats(this);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* Creates a ZooKeeperServer instance. It sets everything up, but doesn't
|
|
* Creates a ZooKeeperServer instance. It sets everything up, but doesn't
|
|
* actually start listening for clients until run() is invoked.
|
|
* actually start listening for clients until run() is invoked.
|
|
- *
|
|
|
|
|
|
+ *
|
|
* @param dataDir the directory to put the data
|
|
* @param dataDir the directory to put the data
|
|
*/
|
|
*/
|
|
public ZooKeeperServer(FileTxnSnapLog txnLogFactory, int tickTime,
|
|
public ZooKeeperServer(FileTxnSnapLog txnLogFactory, int tickTime,
|
|
@@ -154,7 +154,7 @@ public class ZooKeeperServer implements SessionExpirer, ServerStats.Provider {
|
|
this.tickTime = tickTime;
|
|
this.tickTime = tickTime;
|
|
this.minSessionTimeout = minSessionTimeout;
|
|
this.minSessionTimeout = minSessionTimeout;
|
|
this.maxSessionTimeout = maxSessionTimeout;
|
|
this.maxSessionTimeout = maxSessionTimeout;
|
|
-
|
|
|
|
|
|
+
|
|
LOG.info("Created server with tickTime " + tickTime
|
|
LOG.info("Created server with tickTime " + tickTime
|
|
+ " minSessionTimeout " + getMinSessionTimeout()
|
|
+ " minSessionTimeout " + getMinSessionTimeout()
|
|
+ " maxSessionTimeout " + getMaxSessionTimeout()
|
|
+ " maxSessionTimeout " + getMaxSessionTimeout()
|
|
@@ -163,7 +163,7 @@ public class ZooKeeperServer implements SessionExpirer, ServerStats.Provider {
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * creates a zookeeperserver instance.
|
|
|
|
|
|
+ * creates a zookeeperserver instance.
|
|
* @param txnLogFactory the file transaction snapshot logging class
|
|
* @param txnLogFactory the file transaction snapshot logging class
|
|
* @param tickTime the ticktime for the server
|
|
* @param tickTime the ticktime for the server
|
|
* @param treeBuilder the datatree builder
|
|
* @param treeBuilder the datatree builder
|
|
@@ -174,7 +174,7 @@ public class ZooKeeperServer implements SessionExpirer, ServerStats.Provider {
|
|
this(txnLogFactory, tickTime, -1, -1, treeBuilder,
|
|
this(txnLogFactory, tickTime, -1, -1, treeBuilder,
|
|
new ZKDatabase(txnLogFactory));
|
|
new ZKDatabase(txnLogFactory));
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
public ServerStats serverStats() {
|
|
public ServerStats serverStats() {
|
|
return serverStats;
|
|
return serverStats;
|
|
}
|
|
}
|
|
@@ -230,7 +230,7 @@ public class ZooKeeperServer implements SessionExpirer, ServerStats.Provider {
|
|
public ZKDatabase getZKDatabase() {
|
|
public ZKDatabase getZKDatabase() {
|
|
return this.zkDb;
|
|
return this.zkDb;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* set the zkdatabase for this zookeeper server
|
|
* set the zkdatabase for this zookeeper server
|
|
* @param zkDb
|
|
* @param zkDb
|
|
@@ -238,7 +238,7 @@ public class ZooKeeperServer implements SessionExpirer, ServerStats.Provider {
|
|
public void setZKDatabase(ZKDatabase zkDb) {
|
|
public void setZKDatabase(ZKDatabase zkDb) {
|
|
this.zkDb = zkDb;
|
|
this.zkDb = zkDb;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* Restore sessions and data
|
|
* Restore sessions and data
|
|
*/
|
|
*/
|
|
@@ -252,7 +252,7 @@ public class ZooKeeperServer implements SessionExpirer, ServerStats.Provider {
|
|
deadSessions.add(session);
|
|
deadSessions.add(session);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- zkDb.setDataTreeInit(true);
|
|
|
|
|
|
+
|
|
for (long session : deadSessions) {
|
|
for (long session : deadSessions) {
|
|
// XXX: Is lastProcessedZxid really the best thing to use?
|
|
// XXX: Is lastProcessedZxid really the best thing to use?
|
|
killSession(session, zkDb.getDataTreeLastProcessedZxid());
|
|
killSession(session, zkDb.getDataTreeLastProcessedZxid());
|
|
@@ -273,7 +273,7 @@ public class ZooKeeperServer implements SessionExpirer, ServerStats.Provider {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* This should be called from a synchronized block on this!
|
|
* This should be called from a synchronized block on this!
|
|
*/
|
|
*/
|
|
@@ -296,10 +296,10 @@ public class ZooKeeperServer implements SessionExpirer, ServerStats.Provider {
|
|
private void close(long sessionId) {
|
|
private void close(long sessionId) {
|
|
submitRequest(null, sessionId, OpCode.closeSession, 0, null, null);
|
|
submitRequest(null, sessionId, OpCode.closeSession, 0, null, null);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
public void closeSession(long sessionId) {
|
|
public void closeSession(long sessionId) {
|
|
LOG.info("Closing session 0x" + Long.toHexString(sessionId));
|
|
LOG.info("Closing session 0x" + Long.toHexString(sessionId));
|
|
-
|
|
|
|
|
|
+
|
|
// we do not want to wait for a session close. send it as soon as we
|
|
// we do not want to wait for a session close. send it as soon as we
|
|
// detect it!
|
|
// detect it!
|
|
close(sessionId);
|
|
close(sessionId);
|
|
@@ -331,7 +331,7 @@ public class ZooKeeperServer implements SessionExpirer, ServerStats.Provider {
|
|
super(msg);
|
|
super(msg);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
void touch(ServerCnxn cnxn) throws MissingSessionException {
|
|
void touch(ServerCnxn cnxn) throws MissingSessionException {
|
|
if (cnxn == null) {
|
|
if (cnxn == null) {
|
|
return;
|
|
return;
|
|
@@ -350,7 +350,7 @@ public class ZooKeeperServer implements SessionExpirer, ServerStats.Provider {
|
|
try {
|
|
try {
|
|
jmxServerBean = new ZooKeeperServerBean(this);
|
|
jmxServerBean = new ZooKeeperServerBean(this);
|
|
MBeanRegistry.getInstance().register(jmxServerBean, null);
|
|
MBeanRegistry.getInstance().register(jmxServerBean, null);
|
|
-
|
|
|
|
|
|
+
|
|
try {
|
|
try {
|
|
jmxDataTreeBean = new DataTreeBean(zkDb.getDataTree());
|
|
jmxDataTreeBean = new DataTreeBean(zkDb.getDataTree());
|
|
MBeanRegistry.getInstance().register(jmxDataTreeBean, jmxServerBean);
|
|
MBeanRegistry.getInstance().register(jmxDataTreeBean, jmxServerBean);
|
|
@@ -363,19 +363,19 @@ public class ZooKeeperServer implements SessionExpirer, ServerStats.Provider {
|
|
jmxServerBean = null;
|
|
jmxServerBean = null;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
- public void startdata()
|
|
|
|
|
|
+
|
|
|
|
+ public void startdata()
|
|
throws IOException, InterruptedException {
|
|
throws IOException, InterruptedException {
|
|
//check to see if zkDb is not null
|
|
//check to see if zkDb is not null
|
|
if (zkDb == null) {
|
|
if (zkDb == null) {
|
|
zkDb = new ZKDatabase(this.txnLogFactory);
|
|
zkDb = new ZKDatabase(this.txnLogFactory);
|
|
- }
|
|
|
|
|
|
+ }
|
|
if (!zkDb.isInitialized()) {
|
|
if (!zkDb.isInitialized()) {
|
|
loadData();
|
|
loadData();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
- public void startup() {
|
|
|
|
|
|
+
|
|
|
|
+ public void startup() {
|
|
createSessionTracker();
|
|
createSessionTracker();
|
|
setupRequestProcessors();
|
|
setupRequestProcessors();
|
|
|
|
|
|
@@ -539,10 +539,10 @@ public class ZooKeeperServer implements SessionExpirer, ServerStats.Provider {
|
|
|
|
|
|
public void reopenSession(ServerCnxn cnxn, long sessionId, byte[] passwd,
|
|
public void reopenSession(ServerCnxn cnxn, long sessionId, byte[] passwd,
|
|
int sessionTimeout) throws IOException {
|
|
int sessionTimeout) throws IOException {
|
|
- if (!checkPasswd(sessionId, passwd)) {
|
|
|
|
- finishSessionInit(cnxn, false);
|
|
|
|
- } else {
|
|
|
|
|
|
+ if (checkPasswd(sessionId, passwd)) {
|
|
revalidateSession(cnxn, sessionId, sessionTimeout);
|
|
revalidateSession(cnxn, sessionId, sessionTimeout);
|
|
|
|
+ } else {
|
|
|
|
+ finishSessionInit(cnxn, false);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -572,30 +572,31 @@ public class ZooKeeperServer implements SessionExpirer, ServerStats.Provider {
|
|
baos.close();
|
|
baos.close();
|
|
ByteBuffer bb = ByteBuffer.wrap(baos.toByteArray());
|
|
ByteBuffer bb = ByteBuffer.wrap(baos.toByteArray());
|
|
bb.putInt(bb.remaining() - 4).rewind();
|
|
bb.putInt(bb.remaining() - 4).rewind();
|
|
- cnxn.sendBuffer(bb);
|
|
|
|
|
|
+ cnxn.sendBuffer(bb);
|
|
|
|
+
|
|
|
|
+ if (valid) {
|
|
|
|
+ LOG.info("Established session 0x"
|
|
|
|
+ + Long.toHexString(cnxn.getSessionId())
|
|
|
|
+ + " with negotiated timeout " + cnxn.getSessionTimeout()
|
|
|
|
+ + " for client "
|
|
|
|
+ + cnxn.getRemoteSocketAddress());
|
|
|
|
+ } else {
|
|
|
|
|
|
- if (!valid) {
|
|
|
|
LOG.info("Invalid session 0x"
|
|
LOG.info("Invalid session 0x"
|
|
+ Long.toHexString(cnxn.getSessionId())
|
|
+ Long.toHexString(cnxn.getSessionId())
|
|
+ " for client "
|
|
+ " for client "
|
|
+ cnxn.getRemoteSocketAddress()
|
|
+ cnxn.getRemoteSocketAddress()
|
|
+ ", probably expired");
|
|
+ ", probably expired");
|
|
cnxn.sendBuffer(ServerCnxnFactory.closeConn);
|
|
cnxn.sendBuffer(ServerCnxnFactory.closeConn);
|
|
- } else {
|
|
|
|
- LOG.info("Established session 0x"
|
|
|
|
- + Long.toHexString(cnxn.getSessionId())
|
|
|
|
- + " with negotiated timeout " + cnxn.getSessionTimeout()
|
|
|
|
- + " for client "
|
|
|
|
- + cnxn.getRemoteSocketAddress());
|
|
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
cnxn.enableRecv();
|
|
cnxn.enableRecv();
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
LOG.warn("Exception while establishing session, closing", e);
|
|
LOG.warn("Exception while establishing session, closing", e);
|
|
cnxn.close();
|
|
cnxn.close();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
public void closeSession(ServerCnxn cnxn, RequestHeader requestHeader) {
|
|
public void closeSession(ServerCnxn cnxn, RequestHeader requestHeader) {
|
|
closeSession(cnxn.getSessionId());
|
|
closeSession(cnxn.getSessionId());
|
|
}
|
|
}
|
|
@@ -615,7 +616,7 @@ public class ZooKeeperServer implements SessionExpirer, ServerStats.Provider {
|
|
Request si = new Request(cnxn, sessionId, xid, type, bb, authInfo);
|
|
Request si = new Request(cnxn, sessionId, xid, type, bb, authInfo);
|
|
submitRequest(si);
|
|
submitRequest(si);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
public void submitRequest(Request si) {
|
|
public void submitRequest(Request si) {
|
|
if (firstProcessor == null) {
|
|
if (firstProcessor == null) {
|
|
synchronized (this) {
|
|
synchronized (this) {
|
|
@@ -679,7 +680,7 @@ public class ZooKeeperServer implements SessionExpirer, ServerStats.Provider {
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * return the last proceesed id from the
|
|
|
|
|
|
+ * return the last proceesed id from the
|
|
* datatree
|
|
* datatree
|
|
*/
|
|
*/
|
|
public long getLastProcessedZxid() {
|
|
public long getLastProcessedZxid() {
|
|
@@ -688,7 +689,7 @@ public class ZooKeeperServer implements SessionExpirer, ServerStats.Provider {
|
|
|
|
|
|
/**
|
|
/**
|
|
* return the outstanding requests
|
|
* return the outstanding requests
|
|
- * in the queue, which havent been
|
|
|
|
|
|
+ * in the queue, which havent been
|
|
* processed yet
|
|
* processed yet
|
|
*/
|
|
*/
|
|
public long getOutstandingRequests() {
|
|
public long getOutstandingRequests() {
|
|
@@ -696,7 +697,7 @@ public class ZooKeeperServer implements SessionExpirer, ServerStats.Provider {
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * trunccate the log to get in sync with others
|
|
|
|
|
|
+ * trunccate the log to get in sync with others
|
|
* if in a quorum
|
|
* if in a quorum
|
|
* @param zxid the zxid that it needs to get in sync
|
|
* @param zxid the zxid that it needs to get in sync
|
|
* with others
|
|
* with others
|
|
@@ -705,7 +706,7 @@ public class ZooKeeperServer implements SessionExpirer, ServerStats.Provider {
|
|
public void truncateLog(long zxid) throws IOException {
|
|
public void truncateLog(long zxid) throws IOException {
|
|
this.zkDb.truncateLog(zxid);
|
|
this.zkDb.truncateLog(zxid);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
public int getTickTime() {
|
|
public int getTickTime() {
|
|
return tickTime;
|
|
return tickTime;
|
|
}
|
|
}
|
|
@@ -740,7 +741,7 @@ public class ZooKeeperServer implements SessionExpirer, ServerStats.Provider {
|
|
public void setTxnLogFactory(FileTxnSnapLog txnLog) {
|
|
public void setTxnLogFactory(FileTxnSnapLog txnLog) {
|
|
this.txnLogFactory = txnLog;
|
|
this.txnLogFactory = txnLog;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
public FileTxnSnapLog getTxnLogFactory() {
|
|
public FileTxnSnapLog getTxnLogFactory() {
|
|
return this.txnLogFactory;
|
|
return this.txnLogFactory;
|
|
}
|
|
}
|
|
@@ -750,9 +751,9 @@ public class ZooKeeperServer implements SessionExpirer, ServerStats.Provider {
|
|
}
|
|
}
|
|
|
|
|
|
public void dumpEphemerals(PrintWriter pwriter) {
|
|
public void dumpEphemerals(PrintWriter pwriter) {
|
|
- zkDb.dumpEphemerals(pwriter);
|
|
|
|
|
|
+ zkDb.dumpEphemerals(pwriter);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
public void processConnectRequest(ServerCnxn cnxn, ByteBuffer incomingBuffer) throws IOException {
|
|
public void processConnectRequest(ServerCnxn cnxn, ByteBuffer incomingBuffer) throws IOException {
|
|
BinaryInputArchive bia = BinaryInputArchive.getArchive(new ByteBufferInputStream(incomingBuffer));
|
|
BinaryInputArchive bia = BinaryInputArchive.getArchive(new ByteBufferInputStream(incomingBuffer));
|
|
ConnectRequest connReq = new ConnectRequest();
|
|
ConnectRequest connReq = new ConnectRequest();
|
|
@@ -774,7 +775,7 @@ public class ZooKeeperServer implements SessionExpirer, ServerStats.Provider {
|
|
+ cnxn.getRemoteSocketAddress()
|
|
+ cnxn.getRemoteSocketAddress()
|
|
+ "; will be dropped if server is in r-o mode");
|
|
+ "; will be dropped if server is in r-o mode");
|
|
}
|
|
}
|
|
- if (readOnly == false && this instanceof ReadOnlyZooKeeperServer) {
|
|
|
|
|
|
+ if (!readOnly && this instanceof ReadOnlyZooKeeperServer) {
|
|
String msg = "Refusing session request for not-read-only client "
|
|
String msg = "Refusing session request for not-read-only client "
|
|
+ cnxn.getRemoteSocketAddress();
|
|
+ cnxn.getRemoteSocketAddress();
|
|
LOG.info(msg);
|
|
LOG.info(msg);
|
|
@@ -807,7 +808,11 @@ public class ZooKeeperServer implements SessionExpirer, ServerStats.Provider {
|
|
// session is setup
|
|
// session is setup
|
|
cnxn.disableRecv();
|
|
cnxn.disableRecv();
|
|
long sessionId = connReq.getSessionId();
|
|
long sessionId = connReq.getSessionId();
|
|
- if (sessionId != 0) {
|
|
|
|
|
|
+ if (sessionId == 0) {
|
|
|
|
+ LOG.info("Client attempting to establish new session at "
|
|
|
|
+ + cnxn.getRemoteSocketAddress());
|
|
|
|
+ createSession(cnxn, passwd, sessionTimeout);
|
|
|
|
+ } else {
|
|
long clientSessionId = connReq.getSessionId();
|
|
long clientSessionId = connReq.getSessionId();
|
|
LOG.info("Client attempting to renew session 0x"
|
|
LOG.info("Client attempting to renew session 0x"
|
|
+ Long.toHexString(clientSessionId)
|
|
+ Long.toHexString(clientSessionId)
|
|
@@ -815,10 +820,6 @@ public class ZooKeeperServer implements SessionExpirer, ServerStats.Provider {
|
|
serverCnxnFactory.closeSession(sessionId);
|
|
serverCnxnFactory.closeSession(sessionId);
|
|
cnxn.setSessionId(sessionId);
|
|
cnxn.setSessionId(sessionId);
|
|
reopenSession(cnxn, sessionId, passwd, sessionTimeout);
|
|
reopenSession(cnxn, sessionId, passwd, sessionTimeout);
|
|
- } else {
|
|
|
|
- LOG.info("Client attempting to establish new session at "
|
|
|
|
- + cnxn.getRemoteSocketAddress());
|
|
|
|
- createSession(cnxn, passwd, sessionTimeout);
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -826,7 +827,7 @@ public class ZooKeeperServer implements SessionExpirer, ServerStats.Provider {
|
|
if (getGlobalOutstandingLimit() < getInProcess()) {
|
|
if (getGlobalOutstandingLimit() < getInProcess()) {
|
|
return outStandingCount > 0;
|
|
return outStandingCount > 0;
|
|
}
|
|
}
|
|
- return false;
|
|
|
|
|
|
+ return false;
|
|
}
|
|
}
|
|
|
|
|
|
public void processPacket(ServerCnxn cnxn, ByteBuffer incomingBuffer) throws IOException {
|
|
public void processPacket(ServerCnxn cnxn, ByteBuffer incomingBuffer) throws IOException {
|
|
@@ -851,10 +852,18 @@ public class ZooKeeperServer implements SessionExpirer, ServerStats.Provider {
|
|
authReturn = ap.handleAuthentication(cnxn, authPacket.getAuth());
|
|
authReturn = ap.handleAuthentication(cnxn, authPacket.getAuth());
|
|
} catch(RuntimeException e) {
|
|
} catch(RuntimeException e) {
|
|
LOG.warn("Caught runtime exception from AuthenticationProvider: " + scheme + " due to " + e);
|
|
LOG.warn("Caught runtime exception from AuthenticationProvider: " + scheme + " due to " + e);
|
|
- authReturn = KeeperException.Code.AUTHFAILED;
|
|
|
|
|
|
+ authReturn = KeeperException.Code.AUTHFAILED;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- if (authReturn!= KeeperException.Code.OK) {
|
|
|
|
|
|
+ if (authReturn == KeeperException.Code.OK) {
|
|
|
|
+ if (LOG.isDebugEnabled()) {
|
|
|
|
+ LOG.debug("Authentication succeeded for scheme: " + scheme);
|
|
|
|
+ }
|
|
|
|
+ LOG.info("auth success " + cnxn.getRemoteSocketAddress());
|
|
|
|
+ ReplyHeader rh = new ReplyHeader(h.getXid(), 0,
|
|
|
|
+ KeeperException.Code.OK.intValue());
|
|
|
|
+ cnxn.sendResponse(rh, null, null);
|
|
|
|
+ } else {
|
|
if (ap == null) {
|
|
if (ap == null) {
|
|
LOG.warn("No authentication provider for scheme: "
|
|
LOG.warn("No authentication provider for scheme: "
|
|
+ scheme + " has "
|
|
+ scheme + " has "
|
|
@@ -869,15 +878,6 @@ public class ZooKeeperServer implements SessionExpirer, ServerStats.Provider {
|
|
// ... and close connection
|
|
// ... and close connection
|
|
cnxn.sendBuffer(ServerCnxnFactory.closeConn);
|
|
cnxn.sendBuffer(ServerCnxnFactory.closeConn);
|
|
cnxn.disableRecv();
|
|
cnxn.disableRecv();
|
|
- } else {
|
|
|
|
- if (LOG.isDebugEnabled()) {
|
|
|
|
- LOG.debug("Authentication succeeded for scheme: "
|
|
|
|
- + scheme);
|
|
|
|
- }
|
|
|
|
- LOG.info("auth success " + cnxn.getRemoteSocketAddress());
|
|
|
|
- ReplyHeader rh = new ReplyHeader(h.getXid(), 0,
|
|
|
|
- KeeperException.Code.OK.intValue());
|
|
|
|
- cnxn.sendResponse(rh, null, null);
|
|
|
|
}
|
|
}
|
|
return;
|
|
return;
|
|
} else {
|
|
} else {
|
|
@@ -910,7 +910,7 @@ public class ZooKeeperServer implements SessionExpirer, ServerStats.Provider {
|
|
// if using the DIGEST-MD5 mechanism, clientToken will be empty at the beginning of the
|
|
// if using the DIGEST-MD5 mechanism, clientToken will be empty at the beginning of the
|
|
// SASL negotiation process.
|
|
// SASL negotiation process.
|
|
responseToken = saslServer.evaluateResponse(clientToken);
|
|
responseToken = saslServer.evaluateResponse(clientToken);
|
|
- if (saslServer.isComplete() == true) {
|
|
|
|
|
|
+ if (saslServer.isComplete()) {
|
|
String authorizationID = saslServer.getAuthorizationID();
|
|
String authorizationID = saslServer.getAuthorizationID();
|
|
LOG.info("adding SASL authorization for authorizationID: " + authorizationID);
|
|
LOG.info("adding SASL authorization for authorizationID: " + authorizationID);
|
|
cnxn.addAuthInfo(new Id("sasl",authorizationID));
|
|
cnxn.addAuthInfo(new Id("sasl",authorizationID));
|
|
@@ -937,6 +937,4 @@ public class ZooKeeperServer implements SessionExpirer, ServerStats.Provider {
|
|
// wrap SASL response token to client inside a Response object.
|
|
// wrap SASL response token to client inside a Response object.
|
|
return new SetSASLResponse(responseToken);
|
|
return new SetSASLResponse(responseToken);
|
|
}
|
|
}
|
|
-
|
|
|
|
-
|
|
|
|
}
|
|
}
|