mirror of
https://github.com/valitydev/thrift.git
synced 2024-11-07 18:58:51 +00:00
THRIFT-951. java: Add a new isServing() method to TServer
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@1021941 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
21cd3180ef
commit
4c5689269f
@ -237,11 +237,15 @@ public class THsHaServer extends TNonblockingServer {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setServing(true);
|
||||||
|
|
||||||
// this will block while we serve
|
// this will block while we serve
|
||||||
joinSelector();
|
joinSelector();
|
||||||
|
|
||||||
gracefullyShutdownInvokerPool();
|
gracefullyShutdownInvokerPool();
|
||||||
|
|
||||||
|
setServing(false);
|
||||||
|
|
||||||
// do a little cleanup
|
// do a little cleanup
|
||||||
stopListening();
|
stopListening();
|
||||||
|
|
||||||
|
@ -178,9 +178,13 @@ public class TNonblockingServer extends TServer {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setServing(true);
|
||||||
|
|
||||||
// this will block while we serve
|
// this will block while we serve
|
||||||
joinSelector();
|
joinSelector();
|
||||||
|
|
||||||
|
setServing(false);
|
||||||
|
|
||||||
// do a little cleanup
|
// do a little cleanup
|
||||||
stopListening();
|
stopListening();
|
||||||
}
|
}
|
||||||
|
@ -61,6 +61,8 @@ public abstract class TServer {
|
|||||||
*/
|
*/
|
||||||
protected TProtocolFactory outputProtocolFactory_;
|
protected TProtocolFactory outputProtocolFactory_;
|
||||||
|
|
||||||
|
private boolean isServing;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default constructors.
|
* Default constructors.
|
||||||
*/
|
*/
|
||||||
@ -123,4 +125,11 @@ public abstract class TServer {
|
|||||||
*/
|
*/
|
||||||
public void stop() {}
|
public void stop() {}
|
||||||
|
|
||||||
|
public boolean isServing() {
|
||||||
|
return isServing;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setServing(boolean serving) {
|
||||||
|
isServing = serving;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,9 +26,8 @@ import org.apache.thrift.protocol.TProtocol;
|
|||||||
import org.apache.thrift.protocol.TProtocolFactory;
|
import org.apache.thrift.protocol.TProtocolFactory;
|
||||||
import org.apache.thrift.transport.TServerTransport;
|
import org.apache.thrift.transport.TServerTransport;
|
||||||
import org.apache.thrift.transport.TTransport;
|
import org.apache.thrift.transport.TTransport;
|
||||||
import org.apache.thrift.transport.TTransportFactory;
|
|
||||||
import org.apache.thrift.transport.TTransportException;
|
import org.apache.thrift.transport.TTransportException;
|
||||||
|
import org.apache.thrift.transport.TTransportFactory;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
@ -98,6 +97,8 @@ public class TSimpleServer extends TServer {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setServing(true);
|
||||||
|
|
||||||
while (!stopped_) {
|
while (!stopped_) {
|
||||||
TTransport client = null;
|
TTransport client = null;
|
||||||
TProcessor processor = null;
|
TProcessor processor = null;
|
||||||
@ -136,6 +137,7 @@ public class TSimpleServer extends TServer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
setServing(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void stop() {
|
public void stop() {
|
||||||
|
@ -19,26 +19,25 @@
|
|||||||
|
|
||||||
package org.apache.thrift.server;
|
package org.apache.thrift.server;
|
||||||
|
|
||||||
import org.apache.thrift.TException;
|
|
||||||
import org.apache.thrift.TProcessor;
|
|
||||||
import org.apache.thrift.TProcessorFactory;
|
|
||||||
import org.apache.thrift.protocol.TProtocol;
|
|
||||||
import org.apache.thrift.protocol.TProtocolFactory;
|
|
||||||
import org.apache.thrift.protocol.TBinaryProtocol;
|
|
||||||
import org.apache.thrift.transport.TServerTransport;
|
|
||||||
import org.apache.thrift.transport.TTransport;
|
|
||||||
import org.apache.thrift.transport.TTransportException;
|
|
||||||
import org.apache.thrift.transport.TTransportFactory;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.ExecutorService;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
import java.util.concurrent.SynchronousQueue;
|
import java.util.concurrent.SynchronousQueue;
|
||||||
import java.util.concurrent.ThreadPoolExecutor;
|
import java.util.concurrent.ThreadPoolExecutor;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
import org.apache.thrift.TException;
|
||||||
|
import org.apache.thrift.TProcessor;
|
||||||
|
import org.apache.thrift.TProcessorFactory;
|
||||||
|
import org.apache.thrift.protocol.TBinaryProtocol;
|
||||||
|
import org.apache.thrift.protocol.TProtocol;
|
||||||
|
import org.apache.thrift.protocol.TProtocolFactory;
|
||||||
|
import org.apache.thrift.transport.TServerTransport;
|
||||||
|
import org.apache.thrift.transport.TTransport;
|
||||||
|
import org.apache.thrift.transport.TTransportException;
|
||||||
|
import org.apache.thrift.transport.TTransportFactory;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Server which uses Java's built in ThreadPool management to spawn off
|
* Server which uses Java's built in ThreadPool management to spawn off
|
||||||
@ -178,6 +177,7 @@ public class TThreadPoolServer extends TServer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
stopped_ = false;
|
stopped_ = false;
|
||||||
|
setServing(true);
|
||||||
while (!stopped_) {
|
while (!stopped_) {
|
||||||
int failureCount = 0;
|
int failureCount = 0;
|
||||||
try {
|
try {
|
||||||
@ -210,6 +210,7 @@ public class TThreadPoolServer extends TServer {
|
|||||||
now = newnow;
|
now = newnow;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
setServing(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void stop() {
|
public void stop() {
|
||||||
|
Loading…
Reference in New Issue
Block a user