use of org.apache.geode.distributed.internal.InternalDistributedSystem in project geode by apache.
the class PoolImpl method isDurableClient.
public boolean isDurableClient() {
boolean isDurable = false;
InternalDistributedSystem system = InternalDistributedSystem.getAnyInstance();
DistributionConfig config = system.getConfig();
String durableClientId = config.getDurableClientId();
isDurable = durableClientId != null && durableClientId.length() > 0;
return isDurable;
}
use of org.apache.geode.distributed.internal.InternalDistributedSystem in project geode by apache.
the class MemberMBeanBridge method fetchLog.
/**
* @return log of the member.
*/
public String fetchLog(int numLines) {
if (numLines > ManagementConstants.MAX_SHOW_LOG_LINES) {
numLines = ManagementConstants.MAX_SHOW_LOG_LINES;
}
if (numLines == 0 || numLines < 0) {
numLines = ManagementConstants.DEFAULT_SHOW_LOG_LINES;
}
String childTail = null;
String mainTail = null;
try {
InternalDistributedSystem sys = system;
LogWriterAppender lwa = LogWriterAppenders.getAppender(LogWriterAppenders.Identifier.MAIN);
if (lwa != null) {
childTail = BeanUtilFuncs.tailSystemLog(lwa.getChildLogFile(), numLines);
mainTail = BeanUtilFuncs.tailSystemLog(sys.getConfig(), numLines);
if (mainTail == null) {
mainTail = LocalizedStrings.TailLogResponse_NO_LOG_FILE_WAS_SPECIFIED_IN_THE_CONFIGURATION_MESSAGES_WILL_BE_DIRECTED_TO_STDOUT.toLocalizedString();
}
} else {
Assert.assertTrue(false, "TailLogRequest/Response processed in application vm with shared logging.");
}
} catch (IOException e) {
logger.warn(LocalizedMessage.create(LocalizedStrings.TailLogResponse_ERROR_OCCURRED_WHILE_READING_SYSTEM_LOG__0, e));
mainTail = "";
}
if (childTail == null && mainTail == null) {
return LocalizedStrings.SystemMemberImpl_NO_LOG_FILE_CONFIGURED_LOG_MESSAGES_WILL_BE_DIRECTED_TO_STDOUT.toLocalizedString();
} else {
StringBuilder result = new StringBuilder();
if (mainTail != null) {
result.append(mainTail);
}
if (childTail != null) {
result.append(getLineSeparator()).append(LocalizedStrings.SystemMemberImpl_TAIL_OF_CHILD_LOG.toLocalizedString()).append(getLineSeparator());
result.append(childTail);
}
return result.toString();
}
}
use of org.apache.geode.distributed.internal.InternalDistributedSystem in project geode by apache.
the class GeodeRedisServer method startRedisServer.
/**
* Helper method to start the server listening for connections. The server is bound to the port
* specified by {@link GeodeRedisServer#serverPort}
*
* @throws IOException
* @throws InterruptedException
*/
private void startRedisServer() throws IOException, InterruptedException {
ThreadFactory selectorThreadFactory = new ThreadFactory() {
private final AtomicInteger counter = new AtomicInteger();
@Override
public Thread newThread(Runnable r) {
Thread t = new Thread(r);
t.setName("GeodeRedisServer-SelectorThread-" + counter.incrementAndGet());
t.setDaemon(true);
return t;
}
};
ThreadFactory workerThreadFactory = new ThreadFactory() {
private final AtomicInteger counter = new AtomicInteger();
@Override
public Thread newThread(Runnable r) {
Thread t = new Thread(r);
t.setName("GeodeRedisServer-WorkerThread-" + counter.incrementAndGet());
return t;
}
};
bossGroup = null;
workerGroup = null;
Class<? extends ServerChannel> socketClass = null;
if (singleThreadPerConnection) {
bossGroup = new OioEventLoopGroup(Integer.MAX_VALUE, selectorThreadFactory);
workerGroup = new OioEventLoopGroup(Integer.MAX_VALUE, workerThreadFactory);
socketClass = OioServerSocketChannel.class;
} else {
bossGroup = new NioEventLoopGroup(this.numSelectorThreads, selectorThreadFactory);
workerGroup = new NioEventLoopGroup(this.numWorkerThreads, workerThreadFactory);
socketClass = NioServerSocketChannel.class;
}
InternalDistributedSystem system = (InternalDistributedSystem) cache.getDistributedSystem();
String pwd = system.getConfig().getRedisPassword();
final byte[] pwdB = Coder.stringToBytes(pwd);
ServerBootstrap b = new ServerBootstrap();
b.group(bossGroup, workerGroup).channel(socketClass).childHandler(new ChannelInitializer<SocketChannel>() {
@Override
public void initChannel(SocketChannel ch) throws Exception {
if (logger.fineEnabled())
logger.fine("GeodeRedisServer-Connection established with " + ch.remoteAddress());
ChannelPipeline p = ch.pipeline();
p.addLast(ByteToCommandDecoder.class.getSimpleName(), new ByteToCommandDecoder());
p.addLast(ExecutionHandlerContext.class.getSimpleName(), new ExecutionHandlerContext(ch, cache, regionCache, GeodeRedisServer.this, pwdB));
}
}).option(ChannelOption.SO_REUSEADDR, true).option(ChannelOption.SO_RCVBUF, getBufferSize()).childOption(ChannelOption.SO_KEEPALIVE, true).childOption(ChannelOption.CONNECT_TIMEOUT_MILLIS, GeodeRedisServer.connectTimeoutMillis).childOption(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT);
// Bind and start to accept incoming connections.
ChannelFuture f = b.bind(new InetSocketAddress(getBindAddress(), serverPort)).sync();
if (this.logger.infoEnabled()) {
String logMessage = "GeodeRedisServer started {" + getBindAddress() + ":" + serverPort + "}, Selector threads: " + this.numSelectorThreads;
if (this.singleThreadPerConnection)
logMessage += ", One worker thread per connection";
else
logMessage += ", Worker threads: " + this.numWorkerThreads;
this.logger.info(logMessage);
}
this.serverChannel = f.channel();
}
use of org.apache.geode.distributed.internal.InternalDistributedSystem in project geode by apache.
the class ClientRegionFactoryJUnitTest method tearDown.
@After
public void tearDown() throws Exception {
InternalDistributedSystem ids = InternalDistributedSystem.getAnyInstance();
if (ids != null && ids.isConnected()) {
if (r1 != null) {
this.cleanUpRegion(r1);
}
if (r2 != null) {
this.cleanUpRegion(r2);
}
if (r3 != null) {
this.cleanUpRegion(r3);
}
if (sr1 != null) {
this.cleanUpRegion(sr1);
}
ids.disconnect();
}
this.distSys = null;
this.cache = null;
}
use of org.apache.geode.distributed.internal.InternalDistributedSystem in project geode by apache.
the class DLockService method removeLockService.
protected static void removeLockService(DLockService service) {
service.removeAllTokens();
InternalDistributedSystem system = null;
synchronized (services) {
DLockService removedService = (DLockService) services.remove(service.getName());
if (removedService == null) {
// another thread beat us to the removal... return
return;
}
if (removedService != service) {
services.put(service.getName(), removedService);
} else {
service.getStats().incServices(-1);
}
system = removedService.getDistributionManager().getSystem();
}
// if disconnecting and this was the last service, cleanup!
if (services.isEmpty() && system.isDisconnecting()) {
// get rid of stats and thread group...
synchronized (DLockService.class) {
closeStats();
}
}
}
Aggregations