Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

exposed zoie mbean to jmx

  • Loading branch information...
commit 218a89113fa07bd79437a822f3cefd8708c39ea3 1 parent 68dc313
@ymatsuda ymatsuda authored
Showing with 13 additions and 25 deletions.
  1. +13 −25 src/com/sensei/search/nodes/SenseiServer.java
View
38 src/com/sensei/search/nodes/SenseiServer.java
@@ -7,16 +7,19 @@
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
-import java.util.concurrent.ExecutorService;
+
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+import javax.management.StandardMBean;
import org.apache.log4j.Logger;
-import org.jboss.netty.bootstrap.ServerBootstrap;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;
import proj.zoie.api.IndexReaderFactory;
import proj.zoie.api.ZoieIndexReader;
import proj.zoie.impl.indexing.ZoieSystem;
+import proj.zoie.mbean.ZoieSystemAdminMBean;
import com.browseengine.bobo.api.BoboIndexReader;
import com.linkedin.norbert.network.javaapi.MessageHandler;
@@ -25,27 +28,6 @@
private static final Logger logger = Logger.getLogger(SenseiServer.class);
private static final String DEFAULT_CONF_FILE = "sensei-node.spring";
-
- private ServerBootstrap _bootstrap;
- private ExecutorService _bootstrapExecutor;
- private boolean _started;
-
- private final int _port;
-
- private final SenseiSearchContext _ctx;
- private final SenseiIndexLoader _indexLoader;
-
- SenseiServer(int port,SenseiSearchContext ctx, SenseiIndexLoader indexLoader){
- _port = port;
- _started = false;
- _ctx = ctx;
- _indexLoader = indexLoader;
- }
-
- public int getPort(){
- return _port;
- }
-
private static String help(){
StringBuffer buffer = new StringBuffer();
buffer.append("Usage: [id] [port] [partitions] [conf.dir]\n");
@@ -121,18 +103,25 @@ public boolean accept(File dir, String name) {
Map<Integer,SenseiQueryBuilderFactory> builderFactoryMap = new HashMap<Integer, SenseiQueryBuilderFactory>();
SenseiZoieSystemFactory<?> zoieSystemFactory = (SenseiZoieSystemFactory<?>)springCtx.getBean("zoie-system-factory");
SenseiIndexLoaderFactory indexLoaderFactory = (SenseiIndexLoaderFactory)springCtx.getBean("index-loader-factory");
-
+
Map<Integer,IndexReaderFactory<ZoieIndexReader<BoboIndexReader>>> readerFactoryMap =
new HashMap<Integer,IndexReaderFactory<ZoieIndexReader<BoboIndexReader>>>();
final HashSet<ZoieSystem<BoboIndexReader,?>> zoieSystems = new HashSet<ZoieSystem<BoboIndexReader,?>>();
final HashSet<SenseiIndexLoader> indexLoaders = new HashSet<SenseiIndexLoader>();
+ MBeanServer mbeanServer = java.lang.management.ManagementFactory.getPlatformMBeanServer();
+
for (int part : partitions){
//in simple case query builder is the same for each partition
builderFactoryMap.put(part, (SenseiQueryBuilderFactory)springCtx.getBean("query-builder-factory"));
ZoieSystem<BoboIndexReader,?> zoieSystem = zoieSystemFactory.getZoieSystem(part);
+
+ // register ZoieSystemAdminMBean
+ mbeanServer.registerMBean(new StandardMBean(zoieSystem.getAdminMBean(), ZoieSystemAdminMBean.class),
+ new ObjectName(clusterName, "name", "zoie-system-" + part));
+
if(!zoieSystems.contains(zoieSystem))
{
zoieSystem.start();
@@ -149,7 +138,6 @@ public boolean accept(File dir, String name) {
}
SenseiSearchContext ctx = new SenseiSearchContext(builderFactoryMap, readerFactoryMap);
- //SenseiServer server = new SenseiServer(port,ctx, indexLoader);
SenseiNodeMessageHandler msgHandler = new SenseiNodeMessageHandler(ctx);
final SenseiNode node = new SenseiNode(clusterName,id,port,new MessageHandler[] {msgHandler},zookeeperURL,partitions);
Please sign in to comment.
Something went wrong with that request. Please try again.