Skip to content

Package: ServiceConfigurationParentLimitExceededException

ServiceConfigurationParentLimitExceededException

nameinstructionbranchcomplexitylinemethod
ServiceConfigurationParentLimitExceededException(String, KapuaId, long)
M: 34 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 5 C: 0
0%
M: 1 C: 0
0%
getLimitExceededBy()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getScopeId()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getServicePid()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2022 Eurotech and/or its affiliates and others
3: *
4: * This program and the accompanying materials are made
5: * available under the terms of the Eclipse Public License 2.0
6: * which is available at https://www.eclipse.org/legal/epl-2.0/
7: *
8: * SPDX-License-Identifier: EPL-2.0
9: *
10: * Contributors:
11: * Eurotech - initial API and implementation
12: *******************************************************************************/
13: package org.eclipse.kapua.commons.configuration.exception;
14:
15: import org.eclipse.kapua.commons.configuration.AbstractKapuaConfigurableResourceLimitedService;
16: import org.eclipse.kapua.model.id.KapuaId;
17: import org.eclipse.kapua.service.config.KapuaConfigurableService;
18:
19: /**
20: * {@link KapuaConfigurationException} to {@code throw} when an update of a {@link AbstractKapuaConfigurableResourceLimitedService}
21: * {@code maxNumberChildEntities} property exceeds available resources of the parent scope.
22: *
23: * @since 2.0.0
24: */
25: public class ServiceConfigurationParentLimitExceededException extends KapuaConfigurationException {
26:
27: private final String servicePid;
28: private final KapuaId parentScopeId;
29: private final long limitExceededBy;
30:
31: /**
32: * Constructor.
33: *
34: * @param servicePid The {@link KapuaConfigurableService} pid.
35: * @param parentScopeId The parent scope {@link KapuaId} for which limit has been exceeded.
36: * @param limitExceededBy The amount of exceed.
37: * @since 2.0.0
38: */
39: public ServiceConfigurationParentLimitExceededException(String servicePid, KapuaId parentScopeId, long limitExceededBy) {
40:• super(limitExceededBy < 1000000 ? KapuaConfigurationErrorCodes.PARENT_LIMIT_EXCEEDED_BY : KapuaConfigurationErrorCodes.PARENT_LIMIT_EXCEEDED, servicePid, parentScopeId, limitExceededBy);
41:
42: this.servicePid = servicePid;
43: this.parentScopeId = parentScopeId;
44: this.limitExceededBy = limitExceededBy;
45: }
46:
47: /**
48: * Gets the {@link KapuaConfigurableService} pid.
49: *
50: * @return he {@link KapuaConfigurableService} pid.
51: * @since 2.0.0
52: */
53: public String getServicePid() {
54: return servicePid;
55: }
56:
57: /**
58: * Gets the parent scope {@link KapuaId} for which limit has been exceeded.
59: *
60: * @return The parent scope {@link KapuaId} for which limit has been exceeded.
61: * @since 2.0.0
62: */
63: public KapuaId getScopeId() {
64: return parentScopeId;
65: }
66:
67: /**
68: * Gets the amount of exceed.
69: *
70: * @return the amount of exceed.
71: * @since 2.0.0
72: */
73: public long getLimitExceededBy() {
74: return limitExceededBy;
75: }
76: }