Skip to content

Commit

Permalink
Revert "Merge pull request eclipse-vertx#403 from vert-x/jmx_01"
Browse files Browse the repository at this point in the history
This reverts commit 02cbad7, reversing
changes made to e349fb3.
  • Loading branch information
purplefox committed Oct 30, 2012
1 parent 02cbad7 commit b49f3de
Show file tree
Hide file tree
Showing 27 changed files with 13 additions and 726 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@
import org.vertx.java.core.eventbus.impl.hazelcast.HazelcastClusterManager;
import org.vertx.java.core.impl.Context;
import org.vertx.java.core.impl.VertxInternal;
import org.vertx.java.core.jmx.EventBusMXBean;
import org.vertx.java.core.jmx.JmxUtil;
import org.vertx.java.core.json.JsonArray;
import org.vertx.java.core.json.JsonObject;
import org.vertx.java.core.logging.Logger;
Expand All @@ -44,13 +42,12 @@
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;

/**
*
* @author <a href="http://tfox.org">Tim Fox</a>
*/
public class DefaultEventBus implements EventBus, EventBusMXBean {
public class DefaultEventBus implements EventBus {

private static final Logger log = LoggerFactory.getLogger(DefaultEventBus.class);

Expand All @@ -67,16 +64,12 @@ public class DefaultEventBus implements EventBus, EventBusMXBean {
private final AtomicInteger seq = new AtomicInteger(0);
private final String prefix = UUID.randomUUID().toString();

private AtomicLong sentMessageCount = new AtomicLong(0L);
private AtomicLong receivedMessageCount = new AtomicLong(0L);

public DefaultEventBus(VertxInternal vertx) {
// Just some dummy server ID
this.vertx = vertx;
this.serverID = new ServerID(DEFAULT_CLUSTER_PORT, "localhost");
this.server = null;
this.subs = null;
JmxUtil.register(this);
}

public DefaultEventBus(VertxInternal vertx, String hostname) {
Expand All @@ -89,18 +82,6 @@ public DefaultEventBus(VertxInternal vertx, int port, String hostname) {
ClusterManager mgr = new HazelcastClusterManager(vertx);
subs = mgr.getSubsMap("subs");
this.server = setServer();
JmxUtil.unregisterEventBus();
JmxUtil.register(this, port, "localhost");
}

@Override
public long getSentMessageCount() {
return sentMessageCount.get();
}

@Override
public long getReceivedMessageCount() {
return receivedMessageCount.get();
}

public void send(String address, JsonObject message, final Handler<Message<JsonObject>> replyHandler) {
Expand Down Expand Up @@ -296,7 +277,6 @@ public void unregisterHandler(String address, Handler<? extends Message> handler
callCompletionHandler(completionHandler);
}
getHandlerCloseHook(context).entries.remove(new HandlerEntry(address, handler));
JmxUtil.unregister(handler, address);
return;
}
}
Expand Down Expand Up @@ -452,7 +432,6 @@ public void handle(AsyncResult<Void> event) {
}
}
getHandlerCloseHook(context).entries.add(new HandlerEntry(address, handler));
JmxUtil.register(handler, address);
}

private HandlerCloseHook getHandlerCloseHook(Context context) {
Expand Down Expand Up @@ -527,7 +506,6 @@ private void sendRemote(final ServerID theServerID, final BaseMessage message) {
}
}
holder.writeMessage(message);
sentMessageCount.incrementAndGet();
}

private void schedulePing(final ConnectionHolder holder) {
Expand Down Expand Up @@ -605,7 +583,6 @@ public void run() {
}
}
});
receivedMessageCount.incrementAndGet();
}

private static class HandlerHolder {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@

package org.vertx.java.core.http;

import javax.management.MXBean;

import org.vertx.java.core.Handler;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
import org.vertx.java.core.http.impl.ws.hybi17.HandshakeRFC6455;
import org.vertx.java.core.impl.Context;
import org.vertx.java.core.impl.VertxInternal;
import org.vertx.java.core.jmx.JmxUtil;
import org.vertx.java.core.logging.Logger;
import org.vertx.java.core.logging.impl.LoggerFactory;
import org.vertx.java.core.net.impl.*;
Expand All @@ -51,7 +50,7 @@
import java.nio.charset.Charset;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.atomic.AtomicInteger;

import static org.jboss.netty.handler.codec.http.HttpHeaders.Names.CONNECTION;
import static org.jboss.netty.handler.codec.http.HttpHeaders.Values.WEBSOCKET;
Expand Down Expand Up @@ -203,12 +202,10 @@ public ChannelPipeline getPipeline() {
}
}
listening = true;
JmxUtil.register(this, id.host, port);
return this;
}

public void close() {
// TODO JmxUtil.unregister(this, port);
close(null);
}

Expand Down Expand Up @@ -249,10 +246,6 @@ public void close(final Handler<Void> done) {
wsHandler = null;
}

public long getRequestCount() {
return requestCount.get();
}

public HttpServer setSSL(boolean ssl) {
tcpHelper.setSSL(ssl);
return this;
Expand Down Expand Up @@ -383,8 +376,6 @@ private void actualClose(final Context closeContext, final Handler<Void> done) {
conn.internalClose();
}

JmxUtil.unregisterHttpServer(id.host, id.port);

// We need to reset it since sock.internalClose() above can call into the close handlers of sockets on the same thread
// which can cause context id for the thread to change!

Expand All @@ -408,7 +399,7 @@ public void run() {
});
}

private final AtomicLong requestCount = new AtomicLong(0);
private static final AtomicInteger count = new AtomicInteger(0);

public class ServerHandler extends SimpleChannelUpstreamHandler {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@
import org.vertx.java.core.http.HttpServer;
import org.vertx.java.core.http.impl.DefaultHttpClient;
import org.vertx.java.core.http.impl.DefaultHttpServer;
import org.vertx.java.core.jmx.JmxUtil;
import org.vertx.java.core.jmx.VertxMXBean;
import org.vertx.java.core.logging.Logger;
import org.vertx.java.core.logging.impl.LoggerFactory;
import org.vertx.java.core.net.NetClient;
Expand All @@ -51,7 +49,7 @@
/**
* @author <a href="http://tfox.org">Tim Fox</a>
*/
public class DefaultVertx extends VertxInternal implements VertxMXBean {
public class DefaultVertx extends VertxInternal {

private static final Logger log = LoggerFactory.getLogger(DefaultVertx.class);

Expand Down Expand Up @@ -98,7 +96,6 @@ public DefaultVertx(int port, String hostname) {
*/
private void configure() {
this.backgroundPoolSize = Integer.getInteger("vertx.backgroundPoolSize", 20);
JmxUtil.register(this);
}

public NetServer createNetServer() {
Expand Down Expand Up @@ -186,8 +183,7 @@ public ExecutorService getBackgroundPool() {
synchronized (this) {
result = backgroundPool;
if (result == null) {
backgroundPool = result = VertxExecutors.newThreadPool(backgroundPoolSize, "vert.x-worker-thread-", false);
JmxUtil.register(backgroundPool, "pool=Worker");
backgroundPool = result = Executors.newFixedThreadPool(backgroundPoolSize, new VertxThreadFactory("vert.x-worker-thread-"));
orderedFact = new OrderedExecutorFactory(backgroundPool);
}
}
Expand All @@ -202,8 +198,7 @@ public NioWorkerPool getWorkerPool() {
synchronized (this) {
result = workerPool;
if (result == null) {
ExecutorService corePool = VertxExecutors.newThreadPool(corePoolSize, "vert.x-core-thread-", false);
JmxUtil.register(corePool, "pool=Core");
ExecutorService corePool = Executors.newFixedThreadPool(corePoolSize, new VertxThreadFactory("vert.x-core-thread-"));
workerPool = result = new NioWorkerPool(corePool, corePoolSize);
}
}
Expand All @@ -220,8 +215,7 @@ public Executor getAcceptorPool() {
synchronized (this) {
result = acceptorPool;
if (result == null) {
acceptorPool = result = VertxExecutors.newCachedThreadPool("vert.x-acceptor-thread-");
JmxUtil.register(acceptorPool, "pool=Acceptor");
acceptorPool = result = Executors.newCachedThreadPool(new VertxThreadFactory("vert.x-acceptor-thread-"));
}
}
}
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,15 @@
*/
public class VertxThreadFactory implements ThreadFactory {

private final String prefix;
private final AtomicInteger threadCount = new AtomicInteger(0);
private final ThreadGroup group;
private String prefix;
private AtomicInteger threadCount = new AtomicInteger(0);

VertxThreadFactory(String prefix) {
this.prefix = prefix;
this.group = new ThreadGroup(prefix + "group");
}

public Thread newThread(Runnable runnable) {
Thread t = new Thread(group, runnable, prefix + threadCount.getAndIncrement());
Thread t = new Thread(runnable, prefix + threadCount.getAndIncrement());
// All vert.x threads are daemons
t.setDaemon(true);
return t;
Expand Down
Loading

0 comments on commit b49f3de

Please sign in to comment.