/**\r
- * Copyright 2017 ZTE Corporation.\r
+ * Copyright 2017-2020 ZTE Corporation.\r
*\r
* Licensed under the Apache License, Version 2.0 (the "License");\r
* you may not use this file except in compliance with the License.\r
linkIdNodeIdxMap.put(linkId, index);\r
}\r
\r
- /**\r
- * Comparison of the location of different links: 999 the same link: the location of the node\r
- * number less than otherIdIdx in the location of the number (in the otherIdIdx upstream):-1,\r
- * the same link: the node position number is equal to the number of position in the otherIdIdx\r
- * (in the same site otherIdIdx):0, the same link: the node location number is greater than the\r
- * number of locations in otherIdIdx (otherIdIdx) with the site):1,\r
- */\r
- public int CompareLinkPosition(Map<Integer, Integer> otherIdIdx) {\r
- Set<Integer> myIdSet = new HashSet<>();\r
- myIdSet.addAll(this.linkIdNodeIdxMap.keySet());\r
- myIdSet.retainAll(otherIdIdx.keySet());\r
-\r
- if (myIdSet.isEmpty()) {\r
- return 999;\r
- }\r
-\r
- for (int tempLinkId : myIdSet) {\r
- return this.linkIdNodeIdxMap.get(tempLinkId) - otherIdIdx.get(tempLinkId);\r
- }\r
- return 999;\r
- }\r
-\r
public boolean containNode(int linkId, int index) {\r
return linkIdNodeIdxMap.containsKey(linkId) && linkIdNodeIdxMap.get(linkId) == index;\r
}\r
/**\r
- * Copyright 2017 ZTE Corporation.\r
- *\r
+ * Copyright 2017-2020 ZTE Corporation.\r
+ * <p>\r
* Licensed under the Apache License, Version 2.0 (the "License");\r
* you may not use this file except in compliance with the License.\r
* You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
+ * <p>\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ * <p>\r
* Unless required by applicable law or agreed to in writing, software\r
* distributed under the License is distributed on an "AS IS" BASIS,\r
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
import io.dropwizard.db.DataSourceFactory;\r
import io.dropwizard.jdbi.DBIFactory;\r
import io.dropwizard.setup.Environment;\r
-import javax.annotation.PostConstruct;\r
-import javax.inject.Inject;\r
-import javax.inject.Singleton;\r
import lombok.extern.slf4j.Slf4j;\r
import org.jvnet.hk2.annotations.Service;\r
import org.skife.jdbi.v2.DBI;\r
import org.skife.jdbi.v2.Handle;\r
\r
+import javax.annotation.PostConstruct;\r
+import javax.inject.Inject;\r
+import javax.inject.Singleton;\r
+\r
@Singleton\r
@Service\r
@Slf4j\r
private DBIFactory factory = new DBIFactory();\r
\r
@PostConstruct\r
- public void init() {\r
+ public synchronized void init() {\r
if (jdbi == null) {\r
- synchronized (DbDaoUtil.class) {\r
- if (jdbi == null) {\r
- jdbi = factory.build(environmentProvider, dataSourceFactoryProvider, "mysql");\r
- }\r
- }\r
+ jdbi = factory.build(environmentProvider, dataSourceFactoryProvider, "postgres");\r
}\r
}\r
\r
/**
- * Copyright 2017 ZTE Corporation.
+ * Copyright 2017-2020 ZTE Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
-import com.google.gson.Gson;
-import com.google.gson.reflect.TypeToken;
+
import java.util.Date;
import static org.hamcrest.core.IsEqual.equalTo;
import static org.junit.Assert.assertFalse;
public void after() throws Exception {
}
- @Test
- public void testCompareLinkPosition_isEmpty() throws Exception {
- final Map<Integer, Integer> otherIdIdx = new HashMap<>();
- assertThat(999, equalTo(alarm.CompareLinkPosition(otherIdIdx)));
- }
-
- @Test
- public void testCompareLinkPosition_TempLinkId() throws Exception {
- final Map<Integer, Integer> otherIdIdx = new HashMap<>();
- otherIdIdx.put(1, 2);
- alarm.addLinkIdNodeIdx(1, 3);
- assertThat(1, equalTo(alarm.CompareLinkPosition(otherIdIdx)));
- }
-
@Test
public void testContainNode_NoContainLink() throws Exception {
alarm.addLinkIdNodeIdx(1, 2);