public void setData(Serializable data) {
   InetSocketAddress[] sockets =
       (InetSocketAddress[]) ((Address) whitePagesGsd.getAddresses().get("socket")).getObject();
   CommandImpl cmd =
       new CommandImpl("GridServiceDescription.setData", Arrays.asList(new Object[] {data}));
   sendMessage(this.conversationManager, sockets, whitePagesGsd.getId(), cmd);
 }
 public Serializable getData() {
   InetSocketAddress[] sockets =
       (InetSocketAddress[]) ((Address) whitePagesGsd.getAddresses().get("socket")).getObject();
   CommandImpl cmd = new CommandImpl("GridServiceDescription.getData", null);
   Serializable data =
       (Serializable) sendMessage(this.conversationManager, sockets, whitePagesGsd.getId(), cmd);
   return data;
 }
 @Override
 public boolean equals(Object obj) {
   // @TODO: improve equals comparision
   final GridServiceDescription other = (GridServiceDescription) obj;
   if (!this.getId().equals(other.getId())) {
     return false;
   }
   return true;
 }
 public void setServiceInterface(Class cls) {
   InetSocketAddress[] sockets =
       (InetSocketAddress[]) ((Address) whitePagesGsd.getAddresses().get("socket")).getObject();
   CommandImpl cmd =
       new CommandImpl(
           "GridServiceDescription.setServiceInterface", Arrays.asList(new Object[] {id, cls}));
   sendMessage(this.conversationManager, sockets, whitePagesGsd.getId(), cmd);
   this.serviceInterface = cls;
 }
 public void removeAddress(String transport) {
   InetSocketAddress[] sockets =
       (InetSocketAddress[]) ((Address) whitePagesGsd.getAddresses().get("socket")).getObject();
   CommandImpl cmd =
       new CommandImpl(
           "GridServiceDescription.removeAddress", Arrays.asList(new Object[] {id, transport}));
   sendMessage(this.conversationManager, sockets, whitePagesGsd.getId(), cmd);
   this.addresses.remove(transport);
 }
 public GridServiceDescriptionClient(
     GridServiceDescription gsd,
     GridServiceDescription whitePagesGsd,
     ConversationManager conversationManager) {
   this.id = gsd.getId();
   this.serviceInterface = gsd.getServiceInterface();
   this.addresses = new HashMap(gsd.getAddresses());
   this.data = gsd.getData();
   this.whitePagesGsd = whitePagesGsd;
   this.conversationManager = conversationManager;
 }
  public Address addAddress(String transport) {
    InetSocketAddress[] sockets =
        (InetSocketAddress[]) ((Address) whitePagesGsd.getAddresses().get("socket")).getObject();
    CommandImpl cmd =
        new CommandImpl(
            "GridServiceDescription.addAddress", Arrays.asList(new Object[] {this.id, transport}));
    Address address =
        (Address) sendMessage(this.conversationManager, sockets, whitePagesGsd.getId(), cmd);

    this.addresses.put(transport, address);

    return new AddressClient(address, whitePagesGsd, this.conversationManager);
  }
  public <T> GridConnection<T> createConnection(GridServiceDescription<T> gsd) {
    GridConnection<T> conn = null;

    if (this.localAllowed) {
      // internal boolean to disallow local connections
      GridNode gnode = this.grid.getGridNode(gsd.getId());
      if (gnode != null) {
        conn = new LocalGridNodeConnection(gnode);
      }
    }

    if (conn == null) {
      conn = new RemoteGridNodeConnection(this.grid, gsd);
    }

    return conn;
  }
Пример #9
0
 public GridServiceDescription create(String serviceDescriptionId) {
   GridServiceDescription gsd = new GridServiceDescriptionImpl(serviceDescriptionId);
   this.directory.put(gsd.getId(), gsd);
   return gsd;
 }
  public static synchronized GridNode getGridNode(String name, Grid grid, boolean forceRemote) {

    if (logger.isDebugEnabled()) {
      logger.debug(" ### Grid Helper trying to locate GridNode: " + name);
    }

    if (nodeCache.containsKey(name)) {
      logger.debug(" ### Grid Helper found node " + name + " in cache");
      return nodeCache.get(name);
    }

    GridServiceDescription<GridNode> nGsd = grid.get(WhitePages.class).lookup(name);

    if (nGsd == null) {
      if (logger.isDebugEnabled()) {
        logger.error(
            "("
                + Thread.currentThread().getId()
                + ")"
                + Thread.currentThread().getName()
                + " ### Grid Helper DOES NOT Found a Node Descriptor for: "
                + name);
      }
      return null;
    }
    if (logger.isDebugEnabled()) {

      logger.debug(
          "("
              + Thread.currentThread().getId()
              + ")"
              + Thread.currentThread().getName()
              + " ### Grid Helper Found Node Descriptor: "
              + nGsd);
      logger.debug(
          "("
              + Thread.currentThread().getId()
              + ")"
              + Thread.currentThread().getName()
              + " ### \t id: "
              + nGsd.getId());
      logger.debug(
          "("
              + Thread.currentThread().getId()
              + ")"
              + Thread.currentThread().getName()
              + " ### \t Address size: "
              + nGsd.getAddresses().size());
      logger.debug(
          "("
              + Thread.currentThread().getId()
              + ")"
              + Thread.currentThread().getName()
              + " ### \t Addresses: "
              + nGsd.getAddresses());
      for (String key : nGsd.getAddresses().keySet()) {
        logger.debug(
            "("
                + Thread.currentThread().getId()
                + ")"
                + Thread.currentThread().getName()
                + " \t ### Address: "
                + nGsd.getAddresses().get(key));
      }

      logger.debug(
          "("
              + Thread.currentThread().getId()
              + ")"
              + Thread.currentThread().getName()
              + " ### \t Interface: "
              + nGsd.getServiceInterface());
      logger.debug(
          "("
              + Thread.currentThread().getId()
              + ")"
              + Thread.currentThread().getName()
              + " ### \t DATA: "
              + nGsd.getData());
    }

    ConnectionFactoryService csf = grid.get(ConnectionFactoryService.class);
    boolean allowsLocal = csf.isLocalAllowed();
    csf.setLocalAllowed(!forceRemote);
    GridConnection<GridNode> conn = csf.createConnection(nGsd);
    csf.setLocalAllowed(allowsLocal);

    if (logger.isDebugEnabled()) {
      logger.debug(
          "("
              + Thread.currentThread().getId()
              + ")"
              + Thread.currentThread().getName()
              + " ### Grid Helper Create a Conection: "
              + name);
    }
    GridNode node = conn.connect();

    if (logger.isDebugEnabled()) {
      logger.debug(
          "("
              + Thread.currentThread().getId()
              + ")"
              + Thread.currentThread().getName()
              + " ### Grid Helper found GridNode: ("
              + name
              + ") -> "
              + node);
    }

    nodeCache.put(name, node);

    return node;
  }