Skip to content

Commit

Permalink
Revert "Merge pull request eclipse-vertx#122 from pidster/JMX_02"
Browse files Browse the repository at this point in the history
This reverts commit 2c7230c, reversing
changes made to 3b81a8f.
  • Loading branch information
purplefox committed May 17, 2012
1 parent f3a4076 commit 24c6228
Show file tree
Hide file tree
Showing 25 changed files with 31 additions and 517 deletions.
2 changes: 1 addition & 1 deletion src/main/java/org/vertx/java/core/Vertx.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
*
* @author <a href="http://tfox.org">Tim Fox</a>
*/
public abstract class Vertx implements VertxMXBean {
public abstract class Vertx {

private static VertxFactory loadFactory() {
ServiceLoader<VertxFactory> factories = ServiceLoader.load(VertxFactory.class);
Expand Down
27 changes: 0 additions & 27 deletions src/main/java/org/vertx/java/core/VertxMXBean.java

This file was deleted.

2 changes: 1 addition & 1 deletion src/main/java/org/vertx/java/core/eventbus/EventBus.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
*
* @author <a href="http://tfox.org">Tim Fox</a>
*/
public interface EventBus extends EventBusMXBean {
public interface EventBus {

/**
* Send a JSON object as a message
Expand Down
28 changes: 0 additions & 28 deletions src/main/java/org/vertx/java/core/eventbus/EventBusMXBean.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,15 @@ protected BaseMessage(Buffer readBuff) {
}

protected void write(NetSocket socket) {
int length = 1 + 4 + address.length() + 1 + 4 * sender.getHost().length() +
int length = 1 + 4 + address.length() + 1 + 4 * sender.host.length() +
4 + (replyAddress == null ? 0 : replyAddress.length()) +
getBodyLength();
Buffer totBuff = new Buffer(length);
totBuff.appendInt(0);
totBuff.appendByte(type());
writeString(totBuff, address);
totBuff.appendInt(sender.getPort());
writeString(totBuff, sender.getHost());
totBuff.appendInt(sender.port);
writeString(totBuff, sender.host);
if (replyAddress != null) {
writeString(totBuff, replyAddress);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
import org.vertx.java.core.net.impl.ServerID;
import org.vertx.java.core.parsetools.RecordParser;

import java.beans.ConstructorProperties;
import java.util.Collection;
import java.util.ConcurrentModificationException;
import java.util.Map;
Expand All @@ -44,9 +43,6 @@
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.atomic.AtomicLong;

import javax.management.NotificationBroadcasterSupport;

/**
*
Expand All @@ -56,8 +52,6 @@ public class DefaultEventBus implements EventBus {

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

private final NotificationBroadcasterSupport notificationBroadcasterSupport = new NotificationBroadcasterSupport();

private static final Buffer PONG = new Buffer(new byte[] { (byte)1 });
private static final long PING_INTERVAL = 20000;
private static final long PING_REPLY_INTERVAL = 20000;
Expand All @@ -70,12 +64,7 @@ public class DefaultEventBus implements EventBus {
private final ConcurrentMap<String, Map<HandlerHolder, String>> handlers = new ConcurrentHashMap<>();
private final Map<String, ServerID> replyAddressCache = new ConcurrentHashMap<>();
private final Map<String, HandlerInfo> handlersByID = new ConcurrentHashMap<>();

private final AtomicLong sent = new AtomicLong(0);

private final AtomicLong received = new AtomicLong(0);

@ConstructorProperties("vertx")
public DefaultEventBus(VertxInternal vertx) {
// Just some dummy server ID
this.vertx = vertx;
Expand All @@ -84,29 +73,17 @@ public DefaultEventBus(VertxInternal vertx) {
this.subs = null;
}

@ConstructorProperties({"vertx", "hostname"})
public DefaultEventBus(VertxInternal vertx, String hostname) {
this(vertx, DEFAULT_CLUSTER_PORT, hostname);
}

@ConstructorProperties({"vertx", "port", "hostname"})
public DefaultEventBus(VertxInternal vertx, int port, String hostname) {
this.vertx = vertx;
this.serverID = new ServerID(port, hostname);
ClusterManager mgr = new HazelcastClusterManager(vertx);
this.subs = mgr.getSubsMap("subs");
subs = mgr.getSubsMap("subs");
this.server = setServer();
}

@Override
public long getSent() {
return sent.get();
}

@Override
public long getReceived() {
return received.get();
}

public void send(String address, JsonObject message, final Handler<Message<JsonObject>> replyHandler) {
send(new JsonMessage(address, message), replyHandler);
Expand Down Expand Up @@ -297,7 +274,7 @@ public void handle(Buffer buff) {
parser.setOutput(handler);
socket.dataHandler(parser);
}
}).listen(serverID.getPort(), serverID.getHost());
}).listen(serverID.port, serverID.host);
}

private void sendToSubs(Collection<ServerID> subs, BaseMessage message) {
Expand Down Expand Up @@ -463,7 +440,6 @@ private void sendRemote(final ServerID serverID, final BaseMessage message) {
holder.connect(client, serverID, message.address);
}
}
sent.incrementAndGet();
holder.writeMessage(message);
}

Expand Down Expand Up @@ -509,7 +485,6 @@ private void receiveMessage(BaseMessage msg) {
replyAddressCache.put(msg.replyAddress, msg.sender);
}
msg.bus = this;
received.incrementAndGet();
final Map<HandlerHolder, String> map = handlers.get(msg.address);
if (map != null) {
boolean replyHandler = false;
Expand Down Expand Up @@ -615,7 +590,7 @@ public void handle(Buffer data) {
}

void connect(NetClient client, final ServerID serverID, final String address) {
client.connect(serverID.getPort(), serverID.getHost(), new Handler<NetSocket>() {
client.connect(serverID.port, serverID.host, new Handler<NetSocket>() {
public void handle(final NetSocket socket) {
connected(socket, address);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ public HazelcastServerID(ServerID serverID) {

@Override
public void writeData(DataOutput dataOutput) throws IOException {
dataOutput.writeInt(serverID.getPort());
dataOutput.writeUTF(serverID.getHost());
dataOutput.writeInt(serverID.port);
dataOutput.writeUTF(serverID.host);
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/vertx/java/core/http/HttpServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
*
* @author <a href="http://tfox.org">Tim Fox</a>
*/
public interface HttpServer extends HttpServerMXBean {
public interface HttpServer {

/**
* Set the request handler for the server to {@code requestHandler}. As HTTP requests are received by the server,
Expand Down
46 changes: 0 additions & 46 deletions src/main/java/org/vertx/java/core/http/HttpServerMXBean.java

This file was deleted.

25 changes: 2 additions & 23 deletions src/main/java/org/vertx/java/core/http/impl/DefaultHttpServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,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.HandlerHolder;
Expand All @@ -69,8 +68,6 @@
import org.vertx.java.core.net.impl.VertxWorkerPool;

import javax.net.ssl.SSLEngine;

import java.beans.ConstructorProperties;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.URI;
Expand Down Expand Up @@ -112,7 +109,6 @@ public class DefaultHttpServer implements HttpServer {
private HandlerManager<HttpServerRequest> reqHandlerManager = new HandlerManager<>(availableWorkers);
private HandlerManager<ServerWebSocket> wsHandlerManager = new HandlerManager<>(availableWorkers);

@ConstructorProperties("vertx")
public DefaultHttpServer(VertxInternal vertx) {
this.vertx = vertx;
ctx = vertx.getOrAssignContext();
Expand All @@ -127,9 +123,6 @@ public void run() {
}

public HttpServer requestHandler(Handler<HttpServerRequest> requestHandler) {

String simpleName = requestHandler.getClass().getSimpleName();
JMXUtil.register(requestHandler, "org.vertx:type=Handler,type=HTTP,name=%s", simpleName);
this.requestHandler = requestHandler;
return this;
}
Expand All @@ -139,27 +132,13 @@ public Handler<HttpServerRequest> requestHandler() {
}

public HttpServer websocketHandler(Handler<ServerWebSocket> wsHandler) {
String simpleName = requestHandler.getClass().getSimpleName();
JMXUtil.register(requestHandler, "org.vertx:type=Handler,type=WebSocket,name=%s", simpleName);
this.wsHandler = wsHandler;
return this;
}

public Handler<ServerWebSocket> websocketHandler() {
return wsHandler;
}

public ServerID getServerID() {
return id;
}

public int getPort() {
return id.getPort();
}

public String getHost() {
return id.getHost();
}

public HttpServer listen(int port) {
return listen(port, "0.0.0.0");
Expand Down Expand Up @@ -227,7 +206,7 @@ public ChannelPipeline getPipeline() {
} catch (UnknownHostException e) {
log.error("Failed to bind", e);
}
vertx.registerSharedHttpServer(id, this);
vertx.sharedHttpServers().put(id, this);
actualServer = this;
} else {
// Server already exists with that host/port - we will use that
Expand Down Expand Up @@ -406,7 +385,7 @@ public String getTrustStorePassword() {

private void actualClose(final Context closeContext, final Handler<Void> done) {
if (id != null) {
vertx.unregisterSharedHttpServer(id);
vertx.sharedHttpServers().remove(id);
}

for (ServerConnection conn : connectionMap.values()) {
Expand Down
Loading

0 comments on commit 24c6228

Please sign in to comment.