kasakrisz commented on a change in pull request #17: AMBARI-24833. Create cloud 
input/output skeleton.
URL: https://github.com/apache/ambari-logsearch/pull/17#discussion_r229712754
 
 

 ##########
 File path: 
ambari-logsearch-logfeeder/src/main/java/org/apache/ambari/logfeeder/manager/operations/impl/DefaultInputConfigHandler.java
 ##########
 @@ -0,0 +1,164 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 org.apache.ambari.logfeeder.manager.operations.impl;
+
+import org.apache.ambari.logfeeder.manager.operations.InputConfigHandler;
+import org.apache.ambari.logfeeder.input.InputSimulate;
+import org.apache.ambari.logfeeder.manager.InputConfigHolder;
+import org.apache.ambari.logfeeder.plugin.common.AliasUtil;
+import org.apache.ambari.logfeeder.plugin.filter.Filter;
+import org.apache.ambari.logfeeder.plugin.input.Input;
+import org.apache.ambari.logfeeder.plugin.output.Output;
+import 
org.apache.ambari.logsearch.config.api.model.inputconfig.FilterDescriptor;
+import org.apache.ambari.logsearch.config.api.model.inputconfig.InputConfig;
+import 
org.apache.ambari.logsearch.config.api.model.inputconfig.InputDescriptor;
+import org.apache.commons.lang.BooleanUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * Holds input/filter/output operations in default Log Feeder mode.
+ */
+public class DefaultInputConfigHandler implements InputConfigHandler {
+
+  private static final Logger logger = 
LogManager.getLogger(DefaultInputConfigHandler.class);
+
+  @Override
+  public void init(InputConfigHolder inputConfigHolder) throws Exception {
+  }
+
+  @Override
+  public void loadInputs(String serviceName, InputConfigHolder 
inputConfigHolder, InputConfig inputConfig) {
+    loadInputs(serviceName, inputConfigHolder);
+    loadFilters(serviceName, inputConfigHolder);
+  }
+
+  @Override
+  public void assignInputsToOutputs(String serviceName, InputConfigHolder 
inputConfigHolder, InputConfig config) {
+    for (Input input : 
inputConfigHolder.getInputManager().getInputList(serviceName)) {
+      for (Output output : inputConfigHolder.getOutputManager().getOutputs()) {
+        if (input.isOutputRequired(output)) {
+          input.addOutput(output);
+        }
+      }
+    }
+
+    // In case of simulation copies of the output are added for each 
simulation instance, these must be added to the manager
+    for (Output output : InputSimulate.getSimulateOutputs()) {
+      output.setLogSearchConfig(inputConfigHolder.getConfig());
+      inputConfigHolder.getOutputManager().add(output);
+    }
+  }
+
+  private void loadInputs(String serviceName, InputConfigHolder 
inputConfigHolder) {
+    for (InputDescriptor inputDescriptor : 
inputConfigHolder.getInputConfigList()) {
+      if (inputDescriptor == null) {
+        continue;
 
 Review comment:
   Should we log an Error or throw an exception when `inputDescriptor` is 
`null`?

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to