|
@@ -18,22 +18,13 @@
|
|
|
|
|
|
package org.apache.ambari.view.slider;
|
|
|
|
|
|
-import java.io.File;
|
|
|
-import java.io.FileOutputStream;
|
|
|
-import java.io.FilenameFilter;
|
|
|
-import java.io.IOException;
|
|
|
-import java.io.InputStream;
|
|
|
-import java.lang.reflect.Field;
|
|
|
-import java.security.PrivilegedExceptionAction;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.HashSet;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
-import java.util.Map.Entry;
|
|
|
-import java.util.Set;
|
|
|
-import java.util.zip.ZipException;
|
|
|
-
|
|
|
+import com.google.gson.Gson;
|
|
|
+import com.google.gson.JsonArray;
|
|
|
+import com.google.gson.JsonElement;
|
|
|
+import com.google.gson.JsonObject;
|
|
|
+import com.google.gson.JsonParser;
|
|
|
+import com.google.inject.Inject;
|
|
|
+import com.google.inject.Singleton;
|
|
|
import org.apache.ambari.view.ViewContext;
|
|
|
import org.apache.ambari.view.slider.clients.AmbariClient;
|
|
|
import org.apache.ambari.view.slider.clients.AmbariCluster;
|
|
@@ -75,13 +66,21 @@ import org.apache.tools.zip.ZipFile;
|
|
|
import org.codehaus.jackson.map.ObjectMapper;
|
|
|
import org.codehaus.jackson.type.TypeReference;
|
|
|
|
|
|
-import com.google.gson.Gson;
|
|
|
-import com.google.gson.JsonArray;
|
|
|
-import com.google.gson.JsonElement;
|
|
|
-import com.google.gson.JsonObject;
|
|
|
-import com.google.gson.JsonParser;
|
|
|
-import com.google.inject.Inject;
|
|
|
-import com.google.inject.Singleton;
|
|
|
+import java.io.File;
|
|
|
+import java.io.FileOutputStream;
|
|
|
+import java.io.FilenameFilter;
|
|
|
+import java.io.IOException;
|
|
|
+import java.io.InputStream;
|
|
|
+import java.lang.reflect.Field;
|
|
|
+import java.security.PrivilegedExceptionAction;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.HashSet;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.Map.Entry;
|
|
|
+import java.util.Set;
|
|
|
+import java.util.zip.ZipException;
|
|
|
|
|
|
@Singleton
|
|
|
public class SliderAppsViewControllerImpl implements SliderAppsViewController {
|
|
@@ -93,13 +92,12 @@ public class SliderAppsViewControllerImpl implements SliderAppsViewController {
|
|
|
@Inject
|
|
|
private AmbariClient ambariClient;
|
|
|
private List<SliderAppType> appTypes;
|
|
|
-
|
|
|
private Integer createAppCounter = -1;
|
|
|
|
|
|
private String getAppsFolderPath() {
|
|
|
return viewContext
|
|
|
- .getAmbariProperty(org.apache.ambari.server.configuration.Configuration.RESOURCES_DIR_KEY)
|
|
|
- + "/apps";
|
|
|
+ .getAmbariProperty(org.apache.ambari.server.configuration.Configuration.RESOURCES_DIR_KEY)
|
|
|
+ + "/apps";
|
|
|
}
|
|
|
|
|
|
private String getAppsCreateFolderPath() {
|
|
@@ -193,7 +191,7 @@ public class SliderAppsViewControllerImpl implements SliderAppsViewController {
|
|
|
|
|
|
private String getApplicationIdString(ApplicationId appId) {
|
|
|
return Long.toString(appId.getClusterTimestamp()) + "_"
|
|
|
- + Integer.toString(appId.getId());
|
|
|
+ + Integer.toString(appId.getId());
|
|
|
}
|
|
|
|
|
|
private ApplicationId getApplicationId(String appIdString) {
|
|
@@ -229,7 +227,7 @@ public class SliderAppsViewControllerImpl implements SliderAppsViewController {
|
|
|
}
|
|
|
|
|
|
private SliderApp createSliderAppObject(ApplicationReport yarnApp,
|
|
|
- Set<String> properties, SliderClient sliderClient) {
|
|
|
+ Set<String> properties, SliderClient sliderClient) {
|
|
|
if (yarnApp == null) {
|
|
|
return null;
|
|
|
}
|
|
@@ -271,12 +269,13 @@ public class SliderAppsViewControllerImpl implements SliderAppsViewController {
|
|
|
if (index > 0 && index < tag.length() - 1) {
|
|
|
String key = tag.substring(0, index).trim();
|
|
|
String value = tag.substring(index + 1).trim();
|
|
|
- if ("name".equals(key))
|
|
|
+ if ("name".equals(key)) {
|
|
|
app.setType(value);
|
|
|
- else if ("version".equals(key))
|
|
|
+ } else if ("version".equals(key)) {
|
|
|
app.setAppVersion(value);
|
|
|
- else if ("description".equals(key))
|
|
|
+ } else if ("description".equals(key)) {
|
|
|
app.setDescription(value);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -310,10 +309,17 @@ public class SliderAppsViewControllerImpl implements SliderAppsViewController {
|
|
|
String jmxUrl = quickLinks.get("JMX");
|
|
|
List<SliderAppType> appTypes = getSliderAppTypes(null);
|
|
|
if (appTypes != null && appTypes.size() > 0) {
|
|
|
- // TODO: Get the correct app type based on name and version
|
|
|
- SliderAppType appType = appTypes.get(0);
|
|
|
- app.setJmx(sliderAppClient.getJmx(jmxUrl, viewContext,
|
|
|
- appType));
|
|
|
+ for (SliderAppType appType : appTypes) {
|
|
|
+ logger.info("TYPE: " + appType.getTypeName() + " " + app.getType());
|
|
|
+ logger.info("VERSION: " + appType.getTypeVersion() + " " + app.getAppVersion());
|
|
|
+ if ((appType.getTypeName() != null && appType.getTypeName().equalsIgnoreCase(app.getType())) &&
|
|
|
+ (appType.getTypeVersion() != null
|
|
|
+ && appType.getTypeVersion().equalsIgnoreCase(app.getAppVersion()))) {
|
|
|
+ app.setJmx(sliderAppClient.getJmx(jmxUrl, viewContext,
|
|
|
+ appType));
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
Map<String, Map<String, String>> configs = sliderAppClient
|
|
@@ -329,8 +335,10 @@ public class SliderAppsViewControllerImpl implements SliderAppsViewController {
|
|
|
Map<String, SliderAppComponent> componentTypeMap = new HashMap<String, SliderAppComponent>();
|
|
|
for (Entry<String, Object> e : description.status.entrySet()) {
|
|
|
@SuppressWarnings("unchecked")
|
|
|
- Map<String, Map<String, Map<String, Object>>> componentsObj = (Map<String, Map<String, Map<String, Object>>>) e
|
|
|
- .getValue();
|
|
|
+ Map<String, Map<String, Map<String, Object>>>
|
|
|
+ componentsObj =
|
|
|
+ (Map<String, Map<String, Map<String, Object>>>) e
|
|
|
+ .getValue();
|
|
|
boolean isLive = "live".equals(e.getKey());
|
|
|
for (Entry<String, Map<String, Map<String, Object>>> componentEntry : componentsObj
|
|
|
.entrySet()) {
|
|
@@ -344,7 +352,7 @@ public class SliderAppsViewControllerImpl implements SliderAppsViewController {
|
|
|
appComponent
|
|
|
.setCompletedContainers(new HashMap<String, Map<String, String>>());
|
|
|
componentTypeMap.put(componentEntry.getKey(),
|
|
|
- appComponent);
|
|
|
+ appComponent);
|
|
|
}
|
|
|
for (Entry<String, Map<String, Object>> containerEntry : componentEntry
|
|
|
.getValue().entrySet()) {
|
|
@@ -357,19 +365,19 @@ public class SliderAppsViewControllerImpl implements SliderAppsViewController {
|
|
|
Object containerPropertyValue = containerValues
|
|
|
.get(containerProperty);
|
|
|
containerDataMap.put(containerProperty,
|
|
|
- containerPropertyValue.toString());
|
|
|
+ containerPropertyValue.toString());
|
|
|
}
|
|
|
if (isLive) {
|
|
|
appComponent.getActiveContainers().put(containerId,
|
|
|
- containerDataMap);
|
|
|
+ containerDataMap);
|
|
|
} else {
|
|
|
appComponent.getCompletedContainers().put(
|
|
|
containerId, containerDataMap);
|
|
|
}
|
|
|
}
|
|
|
appComponent.setInstanceCount(appComponent
|
|
|
- .getActiveContainers().size()
|
|
|
- + appComponent.getCompletedContainers().size());
|
|
|
+ .getActiveContainers().size()
|
|
|
+ + appComponent.getCompletedContainers().size());
|
|
|
}
|
|
|
}
|
|
|
app.setComponents(componentTypeMap);
|
|
@@ -377,16 +385,16 @@ public class SliderAppsViewControllerImpl implements SliderAppsViewController {
|
|
|
} catch (UnknownApplicationInstanceException e) {
|
|
|
logger.warn(
|
|
|
"Unable to determine app components for "
|
|
|
- + yarnApp.getName(), e);
|
|
|
+ + yarnApp.getName(), e);
|
|
|
} catch (YarnException e) {
|
|
|
logger.warn(
|
|
|
"Unable to determine app components for "
|
|
|
- + yarnApp.getName(), e);
|
|
|
+ + yarnApp.getName(), e);
|
|
|
throw new RuntimeException(e.getMessage(), e);
|
|
|
} catch (IOException e) {
|
|
|
logger.warn(
|
|
|
"Unable to determine app components for "
|
|
|
- + yarnApp.getName(), e);
|
|
|
+ + yarnApp.getName(), e);
|
|
|
throw new RuntimeException(e.getMessage(), e);
|
|
|
}
|
|
|
}
|
|
@@ -398,10 +406,9 @@ public class SliderAppsViewControllerImpl implements SliderAppsViewController {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * Creates a new {@link SliderClient} initialized with appropriate
|
|
|
- * configuration. If configuration was not determined, <code>null</code> is
|
|
|
- * returned.
|
|
|
- *
|
|
|
+ * Creates a new {@link SliderClient} initialized with appropriate configuration. If configuration was not determined,
|
|
|
+ * <code>null</code> is returned.
|
|
|
+ *
|
|
|
* @return
|
|
|
*/
|
|
|
protected SliderClient getSliderClient() {
|
|
@@ -418,7 +425,7 @@ public class SliderAppsViewControllerImpl implements SliderAppsViewController {
|
|
|
super.serviceInit(conf);
|
|
|
// Override the default FS client to set the super user.
|
|
|
FileSystem fs = FileSystem.get(FileSystem.getDefaultUri(getConfig()),
|
|
|
- getConfig(), "yarn");
|
|
|
+ getConfig(), "yarn");
|
|
|
SliderFileSystem fileSystem = new SliderFileSystem(fs, getConfig());
|
|
|
Field fsField = SliderClient.class
|
|
|
.getDeclaredField("sliderFileSystem");
|
|
@@ -428,7 +435,7 @@ public class SliderAppsViewControllerImpl implements SliderAppsViewController {
|
|
|
};
|
|
|
try {
|
|
|
sliderClientConfiguration = client.bindArgs(sliderClientConfiguration,
|
|
|
- new String[] { "usage" });
|
|
|
+ new String[]{"usage"});
|
|
|
} catch (Exception e) {
|
|
|
logger.warn("Unable to set SliderClient configs", e);
|
|
|
throw new RuntimeException(e.getMessage(), e);
|
|
@@ -441,16 +448,15 @@ public class SliderAppsViewControllerImpl implements SliderAppsViewController {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * Dynamically determines Slider client configuration. If unable to determine,
|
|
|
- * <code>null</code> is returned.
|
|
|
- *
|
|
|
+ * Dynamically determines Slider client configuration. If unable to determine, <code>null</code> is returned.
|
|
|
+ *
|
|
|
* @return
|
|
|
*/
|
|
|
private Configuration getSliderClientConfiguration() {
|
|
|
AmbariCluster ambariCluster = getAmbariCluster();
|
|
|
if (ambariCluster != null) {
|
|
|
AmbariService zkService = ambariClient.getService(ambariCluster,
|
|
|
- "ZOOKEEPER");
|
|
|
+ "ZOOKEEPER");
|
|
|
if (zkService != null && ambariCluster.getDesiredConfigs() != null
|
|
|
&& ambariCluster.getDesiredConfigs().containsKey("global")
|
|
|
&& ambariCluster.getDesiredConfigs().containsKey("yarn-site")
|
|
@@ -485,7 +491,7 @@ public class SliderAppsViewControllerImpl implements SliderAppsViewController {
|
|
|
yarnConfig.set("yarn.log-aggregation-enable", "true");
|
|
|
yarnConfig.set("yarn.resourcemanager.address", rmAddress);
|
|
|
yarnConfig.set("yarn.resourcemanager.scheduler.address",
|
|
|
- rmSchedulerAddress);
|
|
|
+ rmSchedulerAddress);
|
|
|
yarnConfig.set("fs.defaultFS", hdfsPath);
|
|
|
yarnConfig.set("slider.zookeeper.quorum", zkQuorum.toString());
|
|
|
yarnConfig
|
|
@@ -510,7 +516,7 @@ public class SliderAppsViewControllerImpl implements SliderAppsViewController {
|
|
|
List<ApplicationReport> yarnApps = sliderClient.listSliderInstances(null);
|
|
|
for (ApplicationReport yarnApp : yarnApps) {
|
|
|
SliderApp sliderAppObject = createSliderAppObject(yarnApp, properties,
|
|
|
- sliderClient);
|
|
|
+ sliderClient);
|
|
|
if (sliderAppObject != null) {
|
|
|
sliderApps.add(sliderAppObject);
|
|
|
}
|
|
@@ -577,7 +583,7 @@ public class SliderAppsViewControllerImpl implements SliderAppsViewController {
|
|
|
try {
|
|
|
ZipFile zipFile = new ZipFile(appZip);
|
|
|
Metainfo metainfo = new MetainfoParser().parse(zipFile
|
|
|
- .getInputStream(zipFile.getEntry("metainfo.xml")));
|
|
|
+ .getInputStream(zipFile.getEntry("metainfo.xml")));
|
|
|
// Create app type object
|
|
|
if (metainfo.getServices() != null
|
|
|
&& metainfo.getServices().size() > 0) {
|
|
@@ -609,8 +615,9 @@ public class SliderAppsViewControllerImpl implements SliderAppsViewController {
|
|
|
// Components
|
|
|
ArrayList<SliderAppTypeComponent> appTypeComponentList = new ArrayList<SliderAppTypeComponent>();
|
|
|
for (Component component : service.getComponents()) {
|
|
|
- if ("CLIENT".equals(component.getCategory()))
|
|
|
+ if ("CLIENT".equals(component.getCategory())) {
|
|
|
continue;
|
|
|
+ }
|
|
|
SliderAppTypeComponent appTypeComponent = new SliderAppTypeComponent();
|
|
|
appTypeComponent.setDisplayName(component.getName());
|
|
|
appTypeComponent.setId(component.getName());
|
|
@@ -620,11 +627,11 @@ public class SliderAppsViewControllerImpl implements SliderAppsViewController {
|
|
|
// appTypeComponent.setPriority(component.);
|
|
|
if (component.getMinInstanceCount() != null) {
|
|
|
appTypeComponent.setInstanceCount(Integer.parseInt(component
|
|
|
- .getMinInstanceCount()));
|
|
|
+ .getMinInstanceCount()));
|
|
|
}
|
|
|
if (component.getMaxInstanceCount() != null) {
|
|
|
appTypeComponent.setMaxInstanceCount(Integer
|
|
|
- .parseInt(component.getMaxInstanceCount()));
|
|
|
+ .parseInt(component.getMaxInstanceCount()));
|
|
|
}
|
|
|
if (resourcesJson != null) {
|
|
|
JsonElement componentJson = resourcesJson.getAsJsonObject()
|
|
@@ -632,10 +639,10 @@ public class SliderAppsViewControllerImpl implements SliderAppsViewController {
|
|
|
.get(component.getName());
|
|
|
if (componentJson != null
|
|
|
&& componentJson.getAsJsonObject().has(
|
|
|
- "yarn.role.priority")) {
|
|
|
+ "yarn.role.priority")) {
|
|
|
appTypeComponent.setPriority(Integer.parseInt(componentJson
|
|
|
- .getAsJsonObject().get("yarn.role.priority")
|
|
|
- .getAsString()));
|
|
|
+ .getAsJsonObject().get("yarn.role.priority")
|
|
|
+ .getAsString()));
|
|
|
}
|
|
|
}
|
|
|
appTypeComponent.setCategory(component.getCategory());
|
|
@@ -644,7 +651,7 @@ public class SliderAppsViewControllerImpl implements SliderAppsViewController {
|
|
|
|
|
|
appType.setJmxMetrics(readMetrics(zipFile, "jmx_metrics.json"));
|
|
|
appType.setGangliaMetrics(readMetrics(zipFile,
|
|
|
- "ganglia_metrics.json"));
|
|
|
+ "ganglia_metrics.json"));
|
|
|
|
|
|
appType.setTypeComponents(appTypeComponentList);
|
|
|
appTypes.add(appType);
|
|
@@ -661,16 +668,16 @@ public class SliderAppsViewControllerImpl implements SliderAppsViewController {
|
|
|
}
|
|
|
|
|
|
Map<String, Map<String, Map<String, Metric>>> readMetrics(ZipFile zipFile,
|
|
|
- String fileName) {
|
|
|
+ String fileName) {
|
|
|
Map<String, Map<String, Map<String, Metric>>> metrics = null;
|
|
|
try {
|
|
|
InputStream inputStream = zipFile.getInputStream(zipFile
|
|
|
- .getEntry("jmx_metrics.json"));
|
|
|
+ .getEntry("jmx_metrics.json"));
|
|
|
ObjectMapper mapper = new ObjectMapper();
|
|
|
|
|
|
metrics = mapper.readValue(inputStream,
|
|
|
- new TypeReference<Map<String, Map<String, Map<String, Metric>>>>() {
|
|
|
- });
|
|
|
+ new TypeReference<Map<String, Map<String, Map<String, Metric>>>>() {
|
|
|
+ });
|
|
|
} catch (IOException e) {
|
|
|
logger.info("Error reading metrics. " + e.getMessage());
|
|
|
}
|
|
@@ -688,8 +695,9 @@ public class SliderAppsViewControllerImpl implements SliderAppsViewController {
|
|
|
JsonArray componentsArray = json.get("typeComponents").getAsJsonArray();
|
|
|
String appsCreateFolderPath = getAppsCreateFolderPath();
|
|
|
File appsCreateFolder = new File(appsCreateFolderPath);
|
|
|
- if (!appsCreateFolder.exists())
|
|
|
+ if (!appsCreateFolder.exists()) {
|
|
|
appsCreateFolder.mkdirs();
|
|
|
+ }
|
|
|
int appCount;
|
|
|
synchronized (createAppCounter) {
|
|
|
if (createAppCounter < 0) {
|
|
@@ -699,8 +707,9 @@ public class SliderAppsViewControllerImpl implements SliderAppsViewController {
|
|
|
for (String app : apps) {
|
|
|
try {
|
|
|
int count = Integer.parseInt(app);
|
|
|
- if (count > createAppCounter)
|
|
|
+ if (count > createAppCounter) {
|
|
|
createAppCounter = count;
|
|
|
+ }
|
|
|
} catch (NumberFormatException e) {
|
|
|
}
|
|
|
}
|
|
@@ -708,7 +717,7 @@ public class SliderAppsViewControllerImpl implements SliderAppsViewController {
|
|
|
appCount = ++createAppCounter;
|
|
|
}
|
|
|
File appCreateFolder = new File(appsCreateFolder,
|
|
|
- Integer.toString(appCount));
|
|
|
+ Integer.toString(appCount));
|
|
|
appCreateFolder.mkdirs();
|
|
|
File appConfigJsonFile = new File(appCreateFolder, "appConfig.json");
|
|
|
File resourcesJsonFile = new File(appCreateFolder, "resources.json");
|
|
@@ -719,28 +728,29 @@ public class SliderAppsViewControllerImpl implements SliderAppsViewController {
|
|
|
AmbariCluster cluster = ambariClient.getCluster(clusterInfo);
|
|
|
Map<String, String> coreSiteConfigs = ambariClient.getConfiguration(
|
|
|
clusterInfo, "core-site", cluster.getDesiredConfigs()
|
|
|
- .get("core-site"));
|
|
|
+ .get("core-site"));
|
|
|
String hdfsLocation = coreSiteConfigs.get("fs.defaultFS");
|
|
|
final ActionCreateArgs createArgs = new ActionCreateArgs();
|
|
|
createArgs.template = appConfigJsonFile;
|
|
|
createArgs.resources = resourcesJsonFile;
|
|
|
createArgs.image = new Path(hdfsLocation
|
|
|
- + "/slider/agent/slider-agent.tar.gz");
|
|
|
+ + "/slider/agent/slider-agent.tar.gz");
|
|
|
|
|
|
ClassLoader currentClassLoader = Thread.currentThread()
|
|
|
.getContextClassLoader();
|
|
|
Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
|
|
|
try {
|
|
|
ApplicationId applicationId = UserGroupInformation.getBestUGI(null,
|
|
|
- "yarn").doAs(new PrivilegedExceptionAction<ApplicationId>() {
|
|
|
+ "yarn").doAs(new PrivilegedExceptionAction<ApplicationId>() {
|
|
|
public ApplicationId run() throws IOException, YarnException {
|
|
|
SliderClient sliderClient = getSliderClient();
|
|
|
sliderClient.actionCreate(appName, createArgs);
|
|
|
return sliderClient.applicationId;
|
|
|
}
|
|
|
});
|
|
|
- if (applicationId != null)
|
|
|
+ if (applicationId != null) {
|
|
|
return getApplicationIdString(applicationId);
|
|
|
+ }
|
|
|
} finally {
|
|
|
Thread.currentThread().setContextClassLoader(currentClassLoader);
|
|
|
}
|
|
@@ -749,10 +759,10 @@ public class SliderAppsViewControllerImpl implements SliderAppsViewController {
|
|
|
}
|
|
|
|
|
|
private void saveAppResources(JsonArray componentsArray,
|
|
|
- File resourcesJsonFile) throws IOException {
|
|
|
+ File resourcesJsonFile) throws IOException {
|
|
|
JsonObject resourcesObj = new JsonObject();
|
|
|
resourcesObj.addProperty("schema",
|
|
|
- "http://example.org/specification/v2.0.0");
|
|
|
+ "http://example.org/specification/v2.0.0");
|
|
|
resourcesObj.add("metadata", new JsonObject());
|
|
|
resourcesObj.add("global", new JsonObject());
|
|
|
JsonObject componentsObj = new JsonObject();
|
|
@@ -762,11 +772,11 @@ public class SliderAppsViewControllerImpl implements SliderAppsViewController {
|
|
|
if (inputComponent.has("id")) {
|
|
|
JsonObject componentValue = new JsonObject();
|
|
|
componentValue.addProperty("yarn.role.priority",
|
|
|
- inputComponent.get("priority").getAsString());
|
|
|
+ inputComponent.get("priority").getAsString());
|
|
|
componentValue.addProperty("yarn.component.instances", inputComponent
|
|
|
.get("instanceCount").getAsString());
|
|
|
componentsObj.add(inputComponent.get("id").getAsString(),
|
|
|
- componentValue);
|
|
|
+ componentValue);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -777,13 +787,14 @@ public class SliderAppsViewControllerImpl implements SliderAppsViewController {
|
|
|
fos = new FileOutputStream(resourcesJsonFile);
|
|
|
IOUtils.write(jsonString, fos);
|
|
|
} finally {
|
|
|
- if (fos != null)
|
|
|
+ if (fos != null) {
|
|
|
fos.close();
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private void saveAppConfigs(JsonObject configs, JsonArray componentsArray,
|
|
|
- File appConfigJsonFile) throws IOException {
|
|
|
+ File appConfigJsonFile) throws IOException {
|
|
|
JsonObject appConfigs = new JsonObject();
|
|
|
appConfigs.addProperty("schema", "http://example.org/specification/v2.0.0");
|
|
|
appConfigs.add("metadata", new JsonObject());
|
|
@@ -792,9 +803,10 @@ public class SliderAppsViewControllerImpl implements SliderAppsViewController {
|
|
|
if (componentsArray != null) {
|
|
|
for (int i = 0; i < componentsArray.size(); i++) {
|
|
|
JsonObject inputComponent = componentsArray.get(i).getAsJsonObject();
|
|
|
- if (inputComponent.has("id"))
|
|
|
+ if (inputComponent.has("id")) {
|
|
|
componentsObj.add(inputComponent.get("id").getAsString(),
|
|
|
- new JsonObject());
|
|
|
+ new JsonObject());
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
appConfigs.add("components", componentsObj);
|
|
@@ -804,8 +816,9 @@ public class SliderAppsViewControllerImpl implements SliderAppsViewController {
|
|
|
fos = new FileOutputStream(appConfigJsonFile);
|
|
|
IOUtils.write(jsonString, fos);
|
|
|
} finally {
|
|
|
- if (fos != null)
|
|
|
+ if (fos != null) {
|
|
|
fos.close();
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|