Java Code Examples for java.rmi.Naming#bind()

The following examples show how to use java.rmi.Naming#bind() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ChildVM.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) throws Throwable {
  try {
    int namingPort = Integer.getInteger(DUnitLauncher.RMI_PORT_PARAM).intValue();
    int vmNum = Integer.getInteger(DUnitLauncher.VM_NUM_PARAM).intValue();
    LogWriter log = Log.createLogWriter("dunit-vm-" + vmNum, DUnitLauncher.LOG_LEVEL);
    System.out.println("VM" + vmNum + " is launching");
    DUnitLauncher.initSystemProperties(log);
    MasterRemote holder = (MasterRemote) Naming.lookup("//localhost:" + namingPort + "/" + DUnitLauncher.MASTER_PARAM);
    RemoteTestModule.Master = new FakeMaster();
    DUnitLauncher.locatorPort = holder.getLocatorPort();
    Naming.bind("//localhost:" + namingPort + "/vm" + vmNum, new FakeRemoteTestModule(log));
    holder.signalVMReady();
    //This loop is here so this VM will die even if the master is mean killed.
    while(true) {
      holder.ping();
      Thread.sleep(1000);
    }
  } catch (Throwable t) {
    t.printStackTrace();
    System.exit(1);
  }
}
 
Example 2
Source File: main.java    From sigar-system_runtime with MIT License 6 votes vote down vote up
public static void main(String args[]) {
    try {
        System.setProperty("java.library.path", "monitor_libs");
        if(args.length==0) ip = "192.168.191.5";
        else ip = args[0];
        System.setProperty("java.rmi.server.hostname", ip);
        systemStatusService sss = new systemStatusServiceImpl();
        LocateRegistry.createRegistry(8828);
        Naming.bind("rmi://"+ip+":8828/systemstatus",sss);
        System.out.println("启动成功!"+System.getProperty("java.library.path"));
    } catch (Exception e) {
        System.out.println("创建远程对象发生异常!"); 
        System.out.println(e);
    }
    

}
 
Example 3
Source File: ChildVM.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) throws Throwable {
  try {
    int namingPort = Integer.getInteger(DUnitLauncher.RMI_PORT_PARAM).intValue();
    int vmNum = Integer.getInteger(DUnitLauncher.VM_NUM_PARAM).intValue();
    LogWriter log = Log.createLogWriter("dunit-vm-" + vmNum, DUnitLauncher.LOG_LEVEL);
    System.out.println("VM" + vmNum + " is launching");
    DUnitLauncher.initSystemProperties(log);
    MasterRemote holder = (MasterRemote) Naming.lookup("//localhost:" + namingPort + "/" + DUnitLauncher.MASTER_PARAM);
    RemoteTestModule.Master = new FakeMaster();
    DUnitLauncher.locatorPort = holder.getLocatorPort();
    Naming.bind("//localhost:" + namingPort + "/vm" + vmNum, new FakeRemoteTestModule(log));
    holder.signalVMReady();
    //This loop is here so this VM will die even if the master is mean killed.
    while(true) {
      holder.ping();
      Thread.sleep(1000);
    }
  } catch (Throwable t) {
    t.printStackTrace();
    System.exit(1);
  }
}
 
Example 4
Source File: RemoteBlockingQueueTest.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
 * Initializes this test by binding an instance of
 * <code>RemoteBlockingQueueImpl</code> into the RMI registry hosted
 * in Hydra's master controller VM.
 */
public void setUp() throws Exception {
  String queueName = this.getUniqueName();
  Host host = Host.getHost(0);
  this.queueURL = RmiRegistryHelper.getMasterRegistryURL() + queueName;

  RemoteBlockingQueue queue =
    new RemoteBlockingQueueImpl(QUEUE_CAPACITY);
  DistributedTestCase.getLogWriter().info("Binding queue named \"" + this.queueURL
                           + "\"");
  Naming.bind(this.queueURL, queue);
}
 
Example 5
Source File: RemoteBlockingQueueTest.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
 * Initializes this test by binding an instance of
 * <code>RemoteBlockingQueueImpl</code> into the RMI registry hosted
 * in Hydra's master controller VM.
 */
public void setUp() throws Exception {
  String queueName = this.getUniqueName();
  Host host = Host.getHost(0);
  this.queueURL = RmiRegistryHelper.getMasterRegistryURL() + queueName;

  RemoteBlockingQueue queue =
    new RemoteBlockingQueueImpl(QUEUE_CAPACITY);
  DistributedTestCase.getLogWriter().info("Binding queue named \"" + this.queueURL
                           + "\"");
  Naming.bind(this.queueURL, queue);
}