Example #1
0
  private ServiceRefAmp initService(String serverId) {
    // XXX: needs to be virtual
    String address = "bartender://" + serverId + ClusterServiceKraken.UID;

    ServiceRefAmp serviceRef = _rampManager.service(address);

    return serviceRef;
  }
  @Override
  protected void build(BartenderSystem bartender) {
    if (_bartender != null) {
      throw new IllegalStateException();
    }

    _bartender = bartender;

    ServicesAmp manager = AmpSystem.currentManager();

    manager.service("local://").bind("public:///cluster_root.0");

    _heartbeatImpl = new HeartbeatImpl(_bartender, getServerSelf(), getRoot(), this);

    ServiceRef heartbeatRef =
        manager.newService(_heartbeatImpl).address("public://" + HeartbeatService.PATH).ref();

    HeartbeatLocalImpl heartbeatLocalImpl = new HeartbeatLocalImpl(_bartender, _heartbeatImpl);

    _heartbeat = heartbeatRef.as(HeartbeatService.class);

    _heartbeatLocal = heartbeatRef.pin(heartbeatLocalImpl).as(HeartbeatServiceLocal.class);

    _podHeartbeatImpl =
        new PodHeartbeatImpl(_bartender, getServerSelf(), _heartbeat, _heartbeatLocal);

    ServiceRefAmp podHeartbeatRef =
        manager.newService(_podHeartbeatImpl).address(PodHeartbeatService.PATH).ref();

    _podHeartbeat = podHeartbeatRef.as(PodHeartbeatService.class);

    /*
    PodManagerImpl podManagerImpl = _podHeartbeatImpl.getManager();

    _podManager = podHeartbeatRef.service(podManagerImpl)
                                 .bind("public://" + PodManagerService.PATH)
                                 .as(PodManagerService.class);
                                 */

    PodLocalImpl podServiceImpl;
    podServiceImpl = new PodLocalImpl(_bartender, _podHeartbeatImpl);

    _podService =
        podHeartbeatRef.pin(podServiceImpl).bind(PodLocalService.PATH).as(PodLocalService.class);
  }
Example #3
0
  public InboxQueue(
      ServicesAmp manager,
      QueueDeliverBuilderImpl<MessageAmp> queueBuilder,
      QueueServiceFactoryInbox serviceQueueFactory,
      ServiceConfig config) {
    super(manager);

    _isFiner = log.isLoggable(Level.FINER);

    _inboxMessage = new InboxMessage(this);

    StubAmp stubMain = serviceQueueFactory.stubMain();

    String name = stubMain.name();

    if (name != null) {
    } else if (config.address() != null) {
      name = config.address();
    } else if (config.name() != null) {
      name = config.name();
    } else {
      TypeRef typeRef = TypeRef.of(stubMain.api().getType());
      name = "anon:" + typeRef.rawClass().getSimpleName();
    }

    _anonAddress = name;

    if (config.isPublic()) {
      _serviceRef = new ServiceRefPublic(stubMain, this);
    } else {
      _serviceRef = new ServiceRefLocal(stubMain, this);
    }

    // queueBuilder.setOutboxContext(new OutboxContextAmpImpl(this));
    queueBuilder.setOutboxContext(this);

    _queue = serviceQueueFactory.build(queueBuilder, this);

    _worker = worker(_queue);

    _stubMain = stubMain;

    _isLifecycleAware = stubMain.isLifecycleAware() || !_queue.isSingleWorker();

    long timeout = config.queueTimeout();

    if (timeout < 0) {
      timeout = 60 * 1000L;
    }

    _sendTimeout = timeout;

    QueueFullHandler handler = config.queueFullHandler();

    if (handler == null) {
      handler = manager.queueFullHandler();
    }

    _fullHandler = handler;

    // start(actor);
  }
 protected ServiceRefAmp lookup(ServicesAmp manager, String path) {
   return manager.service("local://" + path);
 }