/*
   * (non-Javadoc)
   *
   * @see org.kaaproject.kaa.server.bootstrap.service.initialization.
   * BootstrapInitializationService#stop()
   */
  @Override
  public void stop() {
    LOG.trace("Stopping Bootstrap Service..." + propertiesToString());

    if (getNodeConfig().isZkEnabled()) {
      stopZk();
    }

    if (bootstrapTransportService != null) {
      bootstrapTransportService.stop();
    }
    LOG.info("Bootstrap Service Stopped.");
  }
  /*
   * (non-Javadoc)
   *
   * @see org.kaaproject.kaa.server.bootstrap.service.initialization.
   * BootstrapInitializationService#start()
   */
  @Override
  public void start() {
    LOG.trace("Starting Bootstrap service..." + propertiesToString());
    try {
      LOG.trace("Bootstrap Service ZK started");
      if (operationsServerListService == null) {
        throw new Exception("Error initializing OperationsServerListService()"); // NOSONAR
      }

      bootstrapTransportService.lookupAndInit();

      if (getNodeConfig().isZkEnabled()) {
        startZk();
        operationsServerListService.init(bootstrapNode);
        bootstrapTransportService.addListener(
            new TransportUpdateListener() {

              @Override
              public void onTransportsStarted(List<TransportMetaData> mdList) {
                BootstrapNodeInfo info = bootstrapNode.getNodeInfo();
                info.setTransports(mdList);
                try {
                  bootstrapNode.updateNodeData(info);
                } catch (IOException ex) {
                  LOG.error("Failed to update bootstrap node info", ex);
                }
              }
            });
      }

      bootstrapTransportService.start();

      LOG.info("Bootstrap Service Started.");
    } catch (Exception ex) {
      LOG.error("Error starting Bootstrap Service", ex);
    }
  }