Example #1
0
  public Optional<BaragonServiceState> getService(String serviceId) {
    final Optional<BaragonService> maybeServiceInfo = stateDatastore.getService(serviceId);

    if (!maybeServiceInfo.isPresent()) {
      return Optional.absent();
    }

    try {
      return Optional.of(
          new BaragonServiceState(
              maybeServiceInfo.get(), stateDatastore.getUpstreamsMap(serviceId).values()));
    } catch (Exception e) {
      throw Throwables.propagate(e);
    }
  }
Example #2
0
 public BaragonResponse enqueueReloadServiceConfigs(String serviceId, boolean noValidate) {
   String requestId = String.format("%s-%s-%s", serviceId, System.currentTimeMillis(), "RELOAD");
   Optional<BaragonService> maybeService = stateDatastore.getService(serviceId);
   if (maybeService.isPresent()) {
     try {
       return requestManager.enqueueRequest(
           buildReloadRequest(maybeService.get(), requestId, noValidate));
     } catch (Exception e) {
       return BaragonResponse.failure(requestId, e.getMessage());
     }
   } else {
     return BaragonResponse.serviceNotFound(requestId, serviceId);
   }
 }
Example #3
0
 private BaragonRequest buildRemoveRequest(
     BaragonService service, String requestId, boolean noValidate, boolean noReload)
     throws Exception {
   List<UpstreamInfo> empty = Collections.emptyList();
   List<UpstreamInfo> remove;
   remove = new ArrayList<>(stateDatastore.getUpstreamsMap(service.getServiceId()).values());
   return new BaragonRequest(
       requestId,
       service,
       empty,
       remove,
       empty,
       Optional.<String>absent(),
       Optional.of(RequestAction.DELETE),
       noValidate,
       noReload);
 }
Example #4
0
 public Collection<BaragonServiceState> getAllServices() {
   return stateDatastore.getGlobalState();
 }