public ClusterManagementService(IClusterService clusterService, IDatabaseEngine database, int youngAgeHours, int oldAgeHours) { ClusterService = clusterService; DatabaseEngine = database; HoursConsideredOld = youngAgeHours; DaysAllowedToStore = oldAgeHours; }
public async Task <HttpResponseMessage> Join(int clusterId, [FromBody] JoinClusterRequest user) { try { if (user == null || String.IsNullOrWhiteSpace(user.UserEmail) || String.IsNullOrWhiteSpace(user.CaptchaResponse)) { return(this.Request.CreateResponse( HttpStatusCode.BadRequest, new BadRequestViewModel("MissingInput", messageResources.Manager.GetString("MissingInput"), "Missing input."))); } // validate captcha. bool captchaValid = await this.captcha.VerifyAsync(user.CaptchaResponse); if (!captchaValid) { return(this.Request.CreateResponse( HttpStatusCode.Forbidden, new BadRequestViewModel("InvalidCaptcha", messageResources.Manager.GetString("InvalidCaptcha"), "Invalid parameter: captcha"))); } ServiceUriBuilder builder = new ServiceUriBuilder("ClusterService"); IClusterService clusterService = ServiceProxy.Create <IClusterService>(builder.ToUri(), new ServicePartitionKey(1)); await clusterService.JoinClusterAsync(clusterId, user.UserEmail); return(this.Request.CreateResponse(HttpStatusCode.Accepted)); } catch (AggregateException ae) { ArgumentException argumentEx = ae.InnerException as ArgumentException; if (argumentEx != null) { return(this.Request.CreateResponse( HttpStatusCode.BadRequest, new BadRequestViewModel("InvalidEmail", messageResources.Manager.GetString("InvalidEmail"), argumentEx.Message))); } JoinClusterFailedException joinFailedEx = ae.InnerException as JoinClusterFailedException; if (joinFailedEx != null) { return(this.Request.CreateResponse( HttpStatusCode.BadRequest, new BadRequestViewModel( joinFailedEx.Reason.ToString(), messageResources.Manager.GetString(joinFailedEx.Reason.ToString()), joinFailedEx.Message))); } return(this.Request.CreateResponse( HttpStatusCode.InternalServerError, new BadRequestViewModel("ServerError", messageResources.Manager.GetString("ServerError"), ae.InnerException.Message))); } catch (Exception e) { return(this.Request.CreateResponse( HttpStatusCode.InternalServerError, new BadRequestViewModel("ServerError", messageResources.Manager.GetString("ServerError"), e.Message))); } }
public ItineraryService(IClusterService clusterService, IDatabaseEngine databaseEngine, int _highDensity, string token) { HIGHDENSITY = _highDensity; DatabaseEngine = databaseEngine; ClusterService = clusterService; WebAppToken = token; }
public LocationController(IClusterService clusterService, IMobileMessagingClient mobileMessagingClient, ICrossedPathsService crossedPathsService, IUserManagementService userManagementService) { Cluster_Service = clusterService; _mobileMessagingClient = mobileMessagingClient; _crossedPathsService = crossedPathsService; UserManagementService = userManagementService; }
public PhotoService( IClusterService clusterService, IPhotoProcessingService photoProcessingService, IFileService fileService, IApplicationLogger appLogger, IPhotoRepository photoRepository, IHashTagRepository hashTagRepository, IPredictionClassRepository predictionClassRepository, IUnitOfWork unitOfWork, IConfiguration configuration) { _photoRepository = photoRepository; _hashTagRepository = hashTagRepository; _predictionClassRepository = predictionClassRepository; _unitOfWork = unitOfWork; _photoProcessingService = photoProcessingService; _fileService = fileService; _clusterService = clusterService; _appLogger = appLogger; _taskFactory = new TaskFactory(); _photosAddress = configuration["appStorage:uploadedImages"]; _hashTagThreshold = double.Parse(configuration["app:hashTagThreshold"]); _maxDefaultHashTags = int.Parse(configuration["app:maxDefaultHashTags"]); }
public CrossedPathsService(IClusterService clusterService, IMobileMessagingClient mobileMessagingClient, IDatabaseEngine databaseEngine, double proximityToCarrier) { _clusterService = clusterService; _mobileMessagingClient = mobileMessagingClient; _databaseEngine = databaseEngine; ProximityToCarrier = proximityToCarrier; }
public AkkaHostedService(ActorSystem actorSystem, ILoggerFactory loggerFactory, IClusterService clusterService) : base(loggerFactory, actorSystem) { this.ActorSystem = actorSystem; this.clusterService = clusterService; this._logger = loggerFactory.CreateLogger <AkkaHostedService>(); }
public IdentifiedGenerateService(IClusterService clusterService) { if (clusterService == null || clusterService.ServerMember == null) { throw new SysException(ExcpetionCode.EX1100000.ToString(), Localization.Sy000000.ToString()); } _idWorker = new IdWorker(clusterService.ServerMember.Id, 1); }
public ClustersController(IClusterService clusterService, IUserService userService, IMapper mapper, ILoggerFactory loggerFactory) : base(userService) { if (loggerFactory != null) { _logger = loggerFactory.CreateLogger("HomePassesController"); } _clusterService = clusterService; _mapper = mapper; }
public SearchService( IClusterService clusterService, IPhotoRepository photoRepository, IConfiguration configuration) { _clusterService = clusterService; _photoRepository = photoRepository; _feedSize = int.Parse(configuration["app:feedSize"]); }
public ClusterController(IClusterService clusterService, IUserManagementService userService, IClusterManagementService clusterManagementService, IDatabaseEngine databaseEngine, IConfiguration configurationManager) { ClusterManagementService = clusterManagementService; Cluster_Service = clusterService; UserManagementService = userService; DatabaseEngine = databaseEngine; //databaseEngine.Integrated_Populate(); //databaseEngine.Set_Totals(new Area("", "", "", "Brooklyn")); //var list = databaseEngine.Get_Totals(new Area("", "", "", "Brooklyn")); Azure_Key = configurationManager["AzureToken"]; }
public void SetUp() { var autoMocker = new AutoMocker(); _cluster = autoMocker.GetMock <ICluster>(); _authenticator = autoMocker.GetMock <IAuthenticator>(); _clusterManager = autoMocker.GetMock <IClusterManager>(); _clusterInfoResult = autoMocker.GetMock <IResult <IClusterInfo> >(); _clusterInfo = autoMocker.GetMock <IClusterInfo>(); _cluster.Setup(x => x.CreateManager()) .Returns(_clusterManager.Object); _target = autoMocker.CreateInstance <ClusterService>(); }
public AdminController( IPhotoService photoService, IClusterService clusterService, ISamplesService samplesService, IResearchService researchService, IChartService chartService, IApplicationLogger appLogger) { _photoService = photoService; _clusterService = clusterService; _samplesService = samplesService; _researchService = researchService; _chartService = chartService; _appLogger = appLogger; }
public ResearchService( IPhotoService photoService, IClusterService clusterService, ISamplesService samplesService, IKMeansResearchResultRepository kMeansResearchRepository, IConfiguration configuration) { _photoService = photoService; _clusterService = clusterService; _samplesService = samplesService; _kMeansResearchRepository = kMeansResearchRepository; _kmeansStages = int.Parse(configuration["research:kmeans:stages"]); _kmeansClustersStart = int.Parse(configuration["research:kmeans:clustersStart"]); _kmeansClustersEnd = int.Parse(configuration["research:kmeans:clustersEnd"]); }
public HostManager(IAwsCredential awsCredential, PlatformDb db, IEventLogger eventLog) { Validate.NotNull(awsCredential, nameof(awsCredential)); this.db = db ?? throw new ArgumentNullException(nameof(db)); this.eventLog = eventLog ?? throw new ArgumentNullException(nameof(eventLog)); var region = AwsRegion.USEast1; // TODO: Configurable ec2 = new Ec2Client(region, awsCredential); ssm = new SsmClient(region, awsCredential); var elb = new ElbClient(region, awsCredential); this.clusterService = new ClusterService(db); this.clusterManager = new ClusterManager(clusterService, elb, eventLog); this.hostService = new HostService(db); this.imageService = new ImageService(db); this.hostTemplateService = new HostTemplateService(db); }
public async Task <IHttpActionResult> Get() { ServiceUriBuilder builder = new ServiceUriBuilder("ClusterService"); IClusterService clusterService = ServiceProxy.Create <IClusterService>(builder.ToUri(), new ServicePartitionKey(1)); IEnumerable <ClusterView> clusters = await clusterService.GetClusterListAsync(); return(this.Ok( clusters.Select( x => new { ClusterId = x.ClusterId, Name = this.GetClusterName(x.ClusterId), ApplicationCount = x.ApplicationCount, ServiceCount = x.ServiceCount, Capacity = this.GetUserCapacity(x.UserCount, x.MaxUsers), UserCount = x.UserCount, MaxUsers = x.MaxUsers, TimeRemaining = x.TimeRemaining > TimeSpan.Zero ? String.Format("{0:hh\\:mm\\:ss}", x.TimeRemaining) : "expired" }))); }
//public ClusterController(IConsulClient consulClient) //{ // var query = consulClient.Catalog.Service("service-cluster").GetAwaiter().GetResult(); // var serviceInstance = query.Response.First(); // clusterService = RestClient // .For<IClusterService>($"{serviceInstance.ServiceAddress}:{serviceInstance.ServicePort}"); //} public ClusterController(IConfiguration configuration) { clusterService = RestClient.For <IClusterService>($"{configuration["Fabio:Url"]}/cluster"); }
public KMean(IClusterService clusterService, IMetric metric) { _clusterService = clusterService; _metric = metric; }
public ClusterManager(IClusterService clusterService, ElbClient elbClient, IEventLogger eventLog) { this.clusterService = clusterService ?? throw new ArgumentNullException(nameof(clusterService)); this.elbClient = elbClient ?? throw new ArgumentNullException(nameof(elbClient)); this.eventLog = eventLog ?? throw new ArgumentNullException(nameof(eventLog)); }
public UserController(IIdentityService identityService, IClusterService clusterService) { _identityService = identityService; _clusterService = clusterService; }
public ClusterController(IClusterService clusterService) { _clusterService = clusterService; }
public SimulationsModule(ISimulationService service, IUserService userService, IClusterService clusterService, IMapService mapService, IVehicleService vehicleService) : base("simulations") { this.RequiresAuthentication(); Get("/", x => { Debug.Log($"Listing simulations"); try { int page = Request.Query["page"]; // TODO: Items per page should be read from personal user settings. // This value should be independent for each module: maps, vehicles and simulation. // But for now 5 is just an arbitrary value to ensure that we don't try and Page a count of 0 int count = Request.Query["count"] > 0 ? Request.Query["count"] : Config.DefaultPageSize; return(service.List(page, count, this.Context.CurrentUser.Identity.Name).Select(sim => { sim.Status = service.GetActualStatus(sim, false); return SimulationResponse.Create(sim); }).ToArray()); } catch (Exception ex) { Debug.LogException(ex); return(Response.AsJson(new { error = $"Failed to list simulations: {ex.Message}" }, HttpStatusCode.InternalServerError)); } }); Get("/{id:long}", x => { long id = x.id; Debug.Log($"Getting simulation with id {id}"); try { var simulation = service.Get(id, this.Context.CurrentUser.Identity.Name); if (simulation.TimeOfDay.HasValue) { simulation.TimeOfDay = DateTime.SpecifyKind(simulation.TimeOfDay.Value, DateTimeKind.Utc); } simulation.Status = service.GetActualStatus(simulation, false); return(SimulationResponse.Create(simulation)); } catch (IndexOutOfRangeException) { Debug.Log($"Simulation with id {id} does not exist"); return(Response.AsJson(new { error = $"Simulation with id {id} does not exist" }, HttpStatusCode.NotFound)); } catch (Exception ex) { Debug.LogException(ex); return(Response.AsJson(new { error = $"Failed to get simulation with id {id}: {ex.Message}" }, HttpStatusCode.InternalServerError)); } }); Post("/", x => { Debug.Log($"Adding new simulation"); try { var req = this.BindAndValidate <SimulationRequest>(); if (!ModelValidationResult.IsValid) { var message = ModelValidationResult.Errors.First().Value.First().ErrorMessage; Debug.Log($"Wrong request: {message}"); return(Response.AsJson(new { error = $"Failed to add simulation: {message}" }, HttpStatusCode.BadRequest)); } var simulation = req.ToModel(this.Context.CurrentUser.Identity.Name); simulation.Status = service.GetActualStatus(simulation, true); if (simulation.Status != "Valid") { throw new Exception($"Simulation is invalid"); } simulation.Status = service.GetActualStatus(simulation, false); long id = service.Add(simulation); Debug.Log($"Simulation added with id {id}"); simulation.Id = id; SIM.LogWeb(SIM.Web.SimulationAddName, simulation.Name); try { SIM.LogWeb(SIM.Web.SimulationAddMapName, mapService.Get(simulation.Map.Value, this.Context.CurrentUser.Identity.Name).Name); if (simulation.Vehicles != null) { foreach (var vehicle in simulation.Vehicles) { var vehicleModel = vehicleService.Get(vehicle.Vehicle, this.Context.CurrentUser.Identity.Name); SIM.LogWeb(SIM.Web.SimulationAddVehicleName, vehicleModel.Name); SIM.LogWeb(SIM.Web.SimulationAddBridgeType, vehicleModel.BridgeType); } } SIM.LogWeb(SIM.Web.SimulationAddAPIOnly, simulation.ApiOnly.ToString()); SIM.LogWeb(SIM.Web.SimulationAddInteractiveMode, simulation.Interactive.ToString()); SIM.LogWeb(SIM.Web.SimulationAddHeadlessMode, simulation.Headless.ToString()); try { SIM.LogWeb(SIM.Web.SimulationAddClusterName, clusterService.Get(simulation.Cluster.Value, this.Context.CurrentUser.Identity.Name).Name); } catch { }; SIM.LogWeb(SIM.Web.SimulationAddUsePredefinedSeed, simulation.Seed.ToString()); SIM.LogWeb(SIM.Web.SimulationAddEnableNPC, simulation.UseTraffic.ToString()); SIM.LogWeb(SIM.Web.SimulationAddRandomPedestrians, simulation.UsePedestrians.ToString()); SIM.LogWeb(SIM.Web.SimulationAddTimeOfDay, simulation.TimeOfDay.ToString()); SIM.LogWeb(SIM.Web.SimulationAddRain, simulation.Rain.ToString()); SIM.LogWeb(SIM.Web.SimulationAddWetness, simulation.Wetness.ToString()); SIM.LogWeb(SIM.Web.SimulationAddFog, simulation.Fog.ToString()); SIM.LogWeb(SIM.Web.SimulationAddCloudiness, simulation.Cloudiness.ToString()); } catch { }; return(SimulationResponse.Create(simulation)); } catch (Exception ex) { Debug.LogException(ex); return(Response.AsJson(new { error = $"Failed to add simulation: {ex.Message}" }, HttpStatusCode.InternalServerError)); } }); Put("/{id:long}", x => { long id = x.id; Debug.Log($"Updating simulation with id {id}"); try { var req = this.BindAndValidate <SimulationRequest>(); if (!ModelValidationResult.IsValid) { var message = ModelValidationResult.Errors.First().Value.First().ErrorMessage; Debug.Log($"Wrong request: {message}"); return(Response.AsJson(new { error = $"Failed to update simulation: {message}" }, HttpStatusCode.BadRequest)); } var original = service.Get(id, Context.CurrentUser.Identity.Name); var simulation = req.ToModel(original.Owner); simulation.Id = id; simulation.Status = service.GetActualStatus(simulation, true); if (simulation.Status != "Valid") { throw new Exception($"Simulation is invalid"); } simulation.Status = service.GetActualStatus(simulation, false); int result = service.Update(simulation); SIM.LogWeb(SIM.Web.SimulationEditName, simulation.Name); try { SIM.LogWeb(SIM.Web.SimulationEditMapName, mapService.Get(simulation.Map.Value, this.Context.CurrentUser.Identity.Name).Name); if (simulation.Vehicles != null) { foreach (var vehicle in simulation.Vehicles) { try { var vehicleModel = vehicleService.Get(vehicle.Vehicle, this.Context.CurrentUser.Identity.Name); SIM.LogWeb(SIM.Web.SimulationEditVehicleName, vehicleModel.Name); SIM.LogWeb(SIM.Web.SimulationEditBridgeType, vehicleModel.BridgeType); } catch { } } } SIM.LogWeb(SIM.Web.SimulationEditAPIOnly, simulation.ApiOnly.ToString()); SIM.LogWeb(SIM.Web.SimulationEditInteractiveMode, simulation.Interactive.ToString()); SIM.LogWeb(SIM.Web.SimulationEditHeadlessMode, simulation.Headless.ToString()); try { SIM.LogWeb(SIM.Web.SimulationEditClusterName, clusterService.Get(simulation.Cluster.Value, this.Context.CurrentUser.Identity.Name).Name); } catch { }; SIM.LogWeb(SIM.Web.SimulationEditUsePredefinedSeed, simulation.Seed.ToString()); SIM.LogWeb(SIM.Web.SimulationEditEnableNPC, simulation.UseTraffic.ToString()); SIM.LogWeb(SIM.Web.SimulationEditRandomPedestrians, simulation.UsePedestrians.ToString()); SIM.LogWeb(SIM.Web.SimulationEditTimeOfDay, simulation.TimeOfDay.ToString()); SIM.LogWeb(SIM.Web.SimulationEditRain, simulation.Rain.ToString()); SIM.LogWeb(SIM.Web.SimulationEditWetness, simulation.Wetness.ToString()); SIM.LogWeb(SIM.Web.SimulationEditFog, simulation.Fog.ToString()); SIM.LogWeb(SIM.Web.SimulationEditCloudiness, simulation.Cloudiness.ToString()); } catch { } if (result > 1) { throw new Exception($"More than one simulation has id {id}"); } else if (result < 1) { throw new IndexOutOfRangeException(); } return(SimulationResponse.Create(simulation)); } catch (IndexOutOfRangeException) { Debug.Log($"Simulation with id {id} does not exist"); return(Response.AsJson(new { error = $"Simulation with id {id} does not exist" }, HttpStatusCode.NotFound)); } catch (Exception ex) { Debug.LogException(ex); return(Response.AsJson(new { error = $"Failed to update simulation with id {id}: {ex.Message}" }, HttpStatusCode.InternalServerError)); } }); Delete("/{id:long}", x => { long id = x.id; Debug.Log($"Removing simulation with id {id}"); try { int result = service.Delete(id, this.Context.CurrentUser.Identity.Name); SIM.LogWeb(SIM.Web.SimulationDelete); if (result > 1) { throw new Exception($"More than one simulation has id {id}"); } if (result < 1) { throw new IndexOutOfRangeException(); } return(new { }); } catch (IndexOutOfRangeException) { Debug.Log($"Simulation with id {id} does not exist"); return(Response.AsJson(new { error = $"Simulation with id {id} does not exist" }, HttpStatusCode.NotFound)); } catch (Exception ex) { Debug.LogException(ex); return(Response.AsJson(new { error = $"Failed to remove simulation with id {id}: {ex.Message}" }, HttpStatusCode.InternalServerError)); } }); Post("/{id:long}/start", x => { long id = x.id; Debug.Log($"Starting simulation with id {id}"); try { var current = service.GetCurrent(this.Context.CurrentUser.Identity.Name); if (current != null) { throw new Exception($"Simulation with id {current.Id} is already running"); } var simulation = service.Get(id, this.Context.CurrentUser.Identity.Name); if (service.GetActualStatus(simulation, false) != "Valid") { simulation.Status = "Invalid"; service.Update(simulation); throw new Exception("Cannot start an invalid simulation"); } service.Start(simulation); SIM.LogWeb(SIM.Web.WebClick, "SimulationStart"); return(new { }); } catch (IndexOutOfRangeException) { Debug.Log($"Simulation with id {id} does not exist"); return(Response.AsJson(new { error = $"Simulation with id {id} does not exist" }, HttpStatusCode.NotFound)); } catch (Exception ex) { Debug.LogException(ex); return(Response.AsJson(new { error = $"Failed to start simulation with id {id}: {ex.Message}" }, HttpStatusCode.InternalServerError)); } }); Post("/{id:long}/stop", x => { long id = x.id; Debug.Log($"Stopping simulation with id {id}"); try { var simulation = service.GetCurrent(this.Context.CurrentUser.Identity.Name); if (simulation == null || simulation.Id != id) { throw new Exception($"Simulation with id {id} is not running"); } service.Stop(); SIM.LogWeb(SIM.Web.WebClick, "SimulationStop"); return(new { }); } catch (Exception ex) { Debug.LogException(ex); return(Response.AsJson(new { error = $"Failed to stop simulation with id {id}: {ex.Message}" }, HttpStatusCode.InternalServerError)); } }); }
public ClustersModule(IClusterService service, IUserService userService) : base("clusters") { this.RequiresAuthentication(); Get("/", x => { Debug.Log($"Listing cluster"); try { string filter = Request.Query["filter"]; int offset = Request.Query["offset"]; // TODO: Items per page should be read from personal user settings. // This value should be independent for each module: maps, vehicles and simulation. // But for now 5 is just an arbitrary value to ensure that we don't try and Page a count of 0 int count = Request.Query["count"] > 0 ? Request.Query["count"] : Config.DefaultPageSize; return(service.List(filter, offset, count, this.Context.CurrentUser.Identity.Name).Select(ClusterResponse.Create).ToArray()); } catch (Exception ex) { Debug.LogException(ex); return(Response.AsJson(new { error = $"Failed to list clusters: {ex.Message}" }, HttpStatusCode.InternalServerError)); } }); Get("/{id:long}", x => { long id = x.id; Debug.Log($"Getting cluster with id {id}"); try { var cluster = service.Get(id, this.Context.CurrentUser.Identity.Name); return(ClusterResponse.Create(cluster)); } catch (IndexOutOfRangeException) { Debug.Log($"Cluster with id {id} does not exist"); return(Response.AsJson(new { error = $"Cluster with id {id} does not exist" }, HttpStatusCode.NotFound)); } catch (Exception ex) { Debug.LogException(ex); return(Response.AsJson(new { error = $"Failed to get cluster with id {id}: {ex.Message}" }, HttpStatusCode.InternalServerError)); } }); Post("/", x => { Debug.Log($"Adding new cluster"); try { var req = this.BindAndValidate <ClusterRequest>(); if (!ModelValidationResult.IsValid) { var message = ModelValidationResult.Errors.First().Value.First().ErrorMessage; Debug.Log($"Validation for adding cluster failed: {message}"); return(Response.AsJson(new { error = $"Failed to add cluster: {message}" }, HttpStatusCode.BadRequest)); } var cluster = req.ToModel(this.Context.CurrentUser.Identity.Name); cluster.Status = "Valid"; long id = service.Add(cluster); Debug.Log($"Cluster added with id {id}"); cluster.Id = id; SIM.LogWeb(SIM.Web.ClusterAddName, cluster.Name); SIM.LogWeb(SIM.Web.ClusterAddIPS, cluster.Ips); return(ClusterResponse.Create(cluster)); } catch (Exception ex) { Debug.LogException(ex); return(Response.AsJson(new { error = $"Failed to add cluster: {ex.Message}" }, HttpStatusCode.InternalServerError)); } }); Put("/{id:long}", x => { long id = x.id; Debug.Log($"Updating cluster with id {id}"); try { if (id == 0) { throw new Exception("Cannot edit default cluster"); } var req = this.BindAndValidate <ClusterRequest>(); if (!ModelValidationResult.IsValid) { var message = ModelValidationResult.Errors.First().Value.First().ErrorMessage; Debug.Log($"Validation for updating cluster failed: {message}"); return(Response.AsJson(new { error = $"Failed to update cluster: {message}" }, HttpStatusCode.BadRequest)); } var cluster = service.Get(id, this.Context.CurrentUser.Identity.Name); cluster.Name = req.name; cluster.Ips = string.Join(",", req.ips); int result = service.Update(cluster); SIM.LogWeb(SIM.Web.ClusterEditName, cluster.Name); SIM.LogWeb(SIM.Web.ClusterEditIPS, cluster.Ips); if (result > 1) { throw new Exception($"More than one cluster has id {id}"); } else if (result < 1) { throw new IndexOutOfRangeException(); } cluster.Status = "Valid"; return(ClusterResponse.Create(cluster)); } catch (IndexOutOfRangeException) { Debug.Log($"Cluster with id {id} does not exist"); return(Response.AsJson(new { error = $"Cluster with id {id} does not exist" }, HttpStatusCode.NotFound)); } catch (Exception ex) { Debug.LogException(ex); return(Response.AsJson(new { error = $"Failed to update cluster with id {id}: {ex.Message}" }, HttpStatusCode.InternalServerError)); } }); Delete("/{id:long}", x => { long id = x.id; Debug.Log($"Removing cluster with id {id}"); try { if (id == 0) { throw new Exception("Cannot remove default cluster"); } try { var clusterModel = service.Get(id, this.Context.CurrentUser.Identity.Name); SIM.LogWeb(SIM.Web.ClusterDeleteName, clusterModel.Name); SIM.LogWeb(SIM.Web.ClusterDeleteIPS, clusterModel.Ips); } catch { }; int result = service.Delete(id, this.Context.CurrentUser.Identity.Name); if (result > 1) { throw new Exception($"More than one cluster has id {id}"); } if (result < 1) { throw new IndexOutOfRangeException(); } return(new { }); } catch (IndexOutOfRangeException) { Debug.Log($"Cluster with id {id} does not exist"); return(Response.AsJson(new { error = $"Cluster with id {id} does not exist" }, HttpStatusCode.NotFound)); } catch (Exception ex) { Debug.LogException(ex); return(Response.AsJson(new { error = $"Failed to remove cluster with id {id}: {ex.Message}" }, HttpStatusCode.InternalServerError)); } }); }
public RamThresholdCheck(IClusterService clusterService, int threshold) : base(clusterService) { ShortName = "Couchbase Bucket RAM Check"; _threshold = threshold; }
public ClusterController(IClusterService cs) { this.clusterService = cs; }
public DocumentThresholdCheck(IClusterService clusterService, int threshold) : base(clusterService) { ShortName = "Couchbase Bucket Document Check"; _threshold = threshold; }
public QueryController(IClusterService clusterService, ClusterProxy clusterProxy) { this._clusterService = clusterService; _clusterProxy = clusterProxy; }
public BucketCheck(IClusterService clusterService) { _clusterService = clusterService; }
public ClusterEffects(IClusterService clusterService) { this.clusterService = clusterService; }