rawlinp commented on a change in pull request #2785: In Traffic Router Support Snapshots which only update Delivery Services URL: https://github.com/apache/trafficcontrol/pull/2785#discussion_r238458238
########## File path: traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/config/SnapshotEventsProcessor.java ########## @@ -0,0 +1,324 @@ +/* + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.comcast.cdn.traffic_control.traffic_router.core.config; + +import com.comcast.cdn.traffic_control.traffic_router.core.cache.Cache; +import com.comcast.cdn.traffic_control.traffic_router.core.cache.Cache.DeliveryServiceReference; +import com.comcast.cdn.traffic_control.traffic_router.core.ds.DeliveryService; +import com.comcast.cdn.traffic_control.traffic_router.core.util.JsonUtils; +import com.comcast.cdn.traffic_control.traffic_router.core.util.JsonUtilsException; +import com.fasterxml.jackson.databind.JsonNode; +import org.apache.log4j.Logger; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.time.Instant; + +public class SnapshotEventsProcessor { + private static final Logger LOGGER = Logger.getLogger(SnapshotEventsProcessor.class); + final private Map<String, DeliveryService> creationEvents = new HashMap<>(); + final private Map<String, DeliveryService> updateEvents = new HashMap<>(); + final private Map<String, DeliveryService> deleteEvents = new HashMap<>(); + final private Map<String, Cache> mappingEvents = new HashMap<>(); + final private List<String> serverModEvents = new ArrayList<>(); + + public List<String> getDeleteCacheEvents() { + return deleteCacheEvents; + } + + final private List<String> deleteCacheEvents = new ArrayList<>(); + private JsonNode existingConfig = null; + private boolean loadall = false; + + public static SnapshotEventsProcessor diffCrConfigs(final JsonNode newSnapDb, + final JsonNode existingDb) throws + JsonUtilsException, ParseException { + LOGGER.info("In diffCrConfigs"); + final SnapshotEventsProcessor sepRet = new SnapshotEventsProcessor(); + + if (newSnapDb == null) + { + final String errstr = "Required parameter 'newSnapDb' was null"; + LOGGER.error(errstr); + JsonUtils.throwException(errstr); + } + // Load the entire crConfig from the snapshot if there isn't one saved on the filesystem + if (existingDb == null || existingDb.size()< 1) { + sepRet.parseDeliveryServices(newSnapDb); + sepRet.loadall = true; + return sepRet; + } + // Load the entire crConfig from the snapshot if it is not version a version supporting Review comment: not version -> version ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services
