clean test environment
[transportpce.git] / tests / honeynode / 2.2.1 / minimal-distribution-core / src / main / java / io / fd / honeycomb / infra / distro / cfgattrs / HoneycombConfiguration.java
1 /*
2  * Copyright (c) 2016 Cisco and/or its affiliates.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at:
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 package io.fd.honeycomb.infra.distro.cfgattrs;
18
19 import com.google.common.base.MoreObjects;
20 import java.util.Optional;
21 import net.jmob.guice.conf.core.BindConfig;
22 import net.jmob.guice.conf.core.InjectConfig;
23 import net.jmob.guice.conf.core.Syntax;
24
25 /**
26  * This is the Java equivalent for honeyconb.json file. We use guice-config library to load all the config attributes
27  * into this class instance.
28  *
29  * The BindConfig annotation tells that honeycomb.json file should be looked up on classpath root.
30  */
31 @BindConfig(value = "honeycomb", syntax = Syntax.JSON)
32 public class HoneycombConfiguration {
33
34     @InjectConfig("persist-context")
35     public Optional<String> persistContext = Optional.of("true");
36     @InjectConfig("persisted-context-path")
37     public String peristContextPath;
38     @InjectConfig("persisted-context-restoration-type")
39     public String persistedContextRestorationType;
40     @InjectConfig("persist-config")
41     public Optional<String> persistConfig = Optional.of("true");
42     @InjectConfig("persisted-config-path")
43     public String peristConfigPath;
44     @InjectConfig("persisted-config-restoration-type")
45     public String persistedConfigRestorationType;
46     @InjectConfig("notification-service-queue-depth")
47     public int notificationServiceQueueDepth;
48
49     public boolean isConfigPersistenceEnabled() {
50         return persistConfig.isPresent() && Boolean.valueOf(persistConfig.get());
51     }
52
53     public boolean isContextPersistenceEnabled() {
54         return persistContext.isPresent() && Boolean.valueOf(persistContext.get());
55     }
56
57     @Override
58     public String toString() {
59         return MoreObjects.toStringHelper(this)
60             .add("peristContextPath", peristContextPath)
61             .add("persistedContextRestorationType", persistedContextRestorationType)
62             .add("peristConfigPath", peristConfigPath)
63             .add("persistedConfigRestorationType", persistedConfigRestorationType)
64             .add("notificationServiceQueueDepth", notificationServiceQueueDepth)
65             .toString();
66     }
67 }