http://git-wip-us.apache.org/repos/asf/eagle/blob/6fd95d5c/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/service/impl/ApplicationProviderServiceImpl.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/service/impl/ApplicationProviderServiceImpl.java b/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/service/impl/ApplicationProviderServiceImpl.java deleted file mode 100644 index f93a4d4..0000000 --- a/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/service/impl/ApplicationProviderServiceImpl.java +++ /dev/null @@ -1,144 +0,0 @@ -/** - * 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 - * <p/> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p/> - * 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.eagle.app.service.impl; - -import com.google.common.base.Preconditions; -import com.google.inject.Inject; -import com.google.inject.Singleton; -import com.typesafe.config.Config; -import org.apache.eagle.app.service.ApplicationProviderLoader; -import org.apache.eagle.app.service.ApplicationProviderService; -import org.apache.eagle.app.spi.ApplicationProvider; -import org.apache.eagle.metadata.model.ApplicationDependency; -import org.apache.eagle.metadata.model.ApplicationDesc; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.Collection; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - -/** - * Support to load application provider from application.provider.config = "providers.xml" configuration file - * or application.provider.dir = "lib/apps" with SPI Class loader - * <p>TODO: hot-manage application provider loading</p> - */ -@Singleton -public class ApplicationProviderServiceImpl implements ApplicationProviderService { - private final Config config; - private static final Logger LOG = LoggerFactory.getLogger(ApplicationProviderServiceImpl.class); - private final ApplicationProviderLoader appProviderLoader; - private static final String APP_PROVIDER_LOADER_CLASS_KEY = "application.provider.loader"; - - @Inject - public ApplicationProviderServiceImpl(Config config) { - LOG.warn("Initializing {}", this.getClass().getCanonicalName()); - this.config = config; - String appProviderLoaderClass = this.config.hasPath(APP_PROVIDER_LOADER_CLASS_KEY) - ? this.config.getString(APP_PROVIDER_LOADER_CLASS_KEY) : ApplicationProviderLoader.getDefaultAppProviderLoader(); - LOG.warn("Initializing {} = {}", APP_PROVIDER_LOADER_CLASS_KEY, appProviderLoaderClass); - appProviderLoader = initializeAppProviderLoader(appProviderLoaderClass); - LOG.warn("Initialized {}", appProviderLoader); - reload(); - } - - private ApplicationProviderLoader initializeAppProviderLoader(String appProviderLoaderClass) { - try { - return (ApplicationProviderLoader) Class.forName(appProviderLoaderClass).getConstructor(Config.class).newInstance(this.config); - } catch (Throwable e) { - LOG.error("Failed to initialize ApplicationProviderLoader: " + appProviderLoaderClass, e); - throw new IllegalStateException("Failed to initialize ApplicationProviderLoader: " + appProviderLoaderClass, e); - } - } - - public synchronized void reload() { - appProviderLoader.reset(); - LOG.warn("Loading application providers ..."); - appProviderLoader.load(); - LOG.warn("Loaded {} application providers", appProviderLoader.getProviders().size()); - validate(); - } - - private void validate() { - final Map<String, ApplicationDesc> viewPathAppDesc = new HashMap<>(); - - for (ApplicationDesc applicationDesc : getApplicationDescs()) { - LOG.debug("Validating {}", applicationDesc.getType()); - - Preconditions.checkNotNull(applicationDesc.getType(), "type is null in " + applicationDesc); - Preconditions.checkNotNull(applicationDesc.getVersion(), "version is null in " + applicationDesc); - Preconditions.checkNotNull(applicationDesc.getName(), "name is null in " + applicationDesc); - - if (applicationDesc.getViewPath() != null) { - if (viewPathAppDesc.containsKey(applicationDesc.getViewPath())) { - throw new IllegalStateException("Duplicated view " + applicationDesc.getViewPath() - + " defined in " + viewPathAppDesc.get(applicationDesc.getViewPath()).getType() + " and " + applicationDesc.getType()); - } else { - viewPathAppDesc.put(applicationDesc.getViewPath(), applicationDesc); - } - } - - // Validate Dependency - LOG.debug("Validating dependency of {}", applicationDesc.getType()); - List<ApplicationDependency> dependencyList = applicationDesc.getDependencies(); - if (dependencyList != null) { - for (ApplicationDependency dependency : dependencyList) { - try { - ApplicationDesc dependencyDesc = getApplicationDescByType(dependency.getType()); - if (dependencyDesc != null && dependency.getVersion() != null) { - if (dependencyDesc.getVersion().equals(dependency.getVersion())) { - LOG.debug("Loaded dependency {} -> {}", applicationDesc.getType(), dependency); - } else { - LOG.warn("Loaded dependency {} -> {}, but the version was mismatched, expected: {}, actual: {}", - applicationDesc.getType(), dependency, dependency.getVersion(), applicationDesc.getVersion()); - } - } else { - assert dependencyDesc != null; - dependency.setVersion(dependencyDesc.getVersion()); - } - } catch (IllegalArgumentException ex) { - if (!dependency.isRequired()) { - LOG.warn("Unable to load dependency {} -> {}", applicationDesc.getType(), dependency, ex); - } else { - LOG.error("Failed to load dependency {} -> {}", applicationDesc.getType(), dependency, ex); - throw new IllegalStateException("Failed to load application providers due to dependency missing " + applicationDesc.getType() + " -> " + dependency, ex); - } - } - } - } - LOG.info("Validated {} successfully", applicationDesc.getType()); - } - } - - public Collection<ApplicationProvider> getProviders() { - return appProviderLoader.getProviders(); - } - - public Collection<ApplicationDesc> getApplicationDescs() { - return getProviders().stream().map(ApplicationProvider::getApplicationDesc).collect(Collectors.toList()); - } - - public ApplicationProvider<?> getApplicationProviderByType(String type) { - return appProviderLoader.getApplicationProviderByType(type); - } - - public ApplicationDesc getApplicationDescByType(String appType) { - return appProviderLoader.getApplicationProviderByType(appType).getApplicationDesc(); - } -}
http://git-wip-us.apache.org/repos/asf/eagle/blob/6fd95d5c/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/service/impl/ApplicationStatusUpdateServiceImpl.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/service/impl/ApplicationStatusUpdateServiceImpl.java b/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/service/impl/ApplicationStatusUpdateServiceImpl.java deleted file mode 100644 index b5bec1b..0000000 --- a/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/service/impl/ApplicationStatusUpdateServiceImpl.java +++ /dev/null @@ -1,132 +0,0 @@ -/** - * 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 - * <p> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p> - * 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.eagle.app.service.impl; - -import com.google.inject.Inject; -import com.google.inject.Singleton; -import org.apache.eagle.app.service.ApplicationOperations; -import org.apache.eagle.metadata.model.ApplicationEntity; -import org.apache.eagle.metadata.service.ApplicationEntityService; -import org.apache.eagle.metadata.service.ApplicationStatusUpdateService; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.Collection; -import java.util.concurrent.TimeUnit; - -@Singleton -public class ApplicationStatusUpdateServiceImpl extends ApplicationStatusUpdateService { - private static final Logger LOG = LoggerFactory.getLogger(ApplicationStatusUpdateServiceImpl.class); - private final ApplicationEntityService applicationEntityService; - private final ApplicationManagementServiceImpl applicationManagementService; - - // default value 30, 30 - private int initialDelay = 30; - private int period = 30; - - - @Inject - public ApplicationStatusUpdateServiceImpl(ApplicationEntityService applicationEntityService, ApplicationManagementServiceImpl applicationManagementService) { - this.applicationEntityService = applicationEntityService; - this.applicationManagementService = applicationManagementService; - } - - @Override - protected void runOneIteration() throws Exception { - LOG.info("Updating application status"); - try { - Collection<ApplicationEntity> applicationEntities = applicationEntityService.findAll(); - if (applicationEntities.size() == 0) { - LOG.info("No application installed yet"); - return; - } - for (ApplicationEntity applicationEntity : applicationEntities) { - if (applicationEntity.getDescriptor().isExecutable()) { - updateApplicationEntityStatus(applicationEntity); - } - } - LOG.info("Updated {} application status", applicationEntities.size()); - } catch (Exception e) { - LOG.error("Failed to update application status", e); - } - } - - @Override - protected Scheduler scheduler() { - return Scheduler.newFixedRateSchedule(initialDelay, period, TimeUnit.SECONDS); - } - - @Override - public void updateApplicationEntityStatus(ApplicationEntity applicationEntity) { - String appUuid = applicationEntity.getUuid(); - ApplicationEntity.Status preStatus = applicationEntity.getStatus(); - try { - ApplicationEntity.Status currentStatus = applicationManagementService.getStatus(new ApplicationOperations.CheckStatusOperation(appUuid)); - if (preStatus == ApplicationEntity.Status.STARTING) { - if (currentStatus == ApplicationEntity.Status.RUNNING) { - // applicationEntityService.delete(applicationEntity); - // applicationEntity.setStatus(ApplicationEntity.Status.RUNNING); - // applicationEntityService.create(applicationEntity); - currentStatus = ApplicationEntity.Status.RUNNING; - // handle the topology corruption case: - } else if (currentStatus == ApplicationEntity.Status.REMOVED) { - // applicationEntityService.delete(applicationEntity); - // applicationEntity.setStatus(ApplicationEntity.Status.INITIALIZED); - // applicationEntityService.create(applicationEntity); - currentStatus = ApplicationEntity.Status.INITIALIZED; - } - } else if (preStatus == ApplicationEntity.Status.STOPPING) { - if (currentStatus == ApplicationEntity.Status.REMOVED) { - // applicationEntityService.delete(applicationEntity); - // applicationEntity.setStatus(ApplicationEntity.Status.INITIALIZED); - // applicationEntityService.create(applicationEntity); - currentStatus = ApplicationEntity.Status.INITIALIZED; - } - } else if (preStatus == ApplicationEntity.Status.RUNNING) { - // handle the topology corruption case: - if (currentStatus == ApplicationEntity.Status.REMOVED) { - // applicationEntityService.delete(applicationEntity); - // applicationEntity.setStatus(ApplicationEntity.Status.INITIALIZED); - // applicationEntityService.create(applicationEntity); - currentStatus = ApplicationEntity.Status.INITIALIZED; - } - } else if (preStatus == ApplicationEntity.Status.INITIALIZED) { - //corner case: when Storm service go down, app status-> initialized, - //then when storm server is up again, storm topology will be launched automatically->active - if (currentStatus == ApplicationEntity.Status.RUNNING) { - // applicationEntityService.delete(applicationEntity); - // applicationEntity.setStatus(ApplicationEntity.Status.RUNNING); - // applicationEntityService.create(applicationEntity); - currentStatus = ApplicationEntity.Status.RUNNING; - } - } - - if (currentStatus == ApplicationEntity.Status.REMOVED) { - currentStatus = ApplicationEntity.Status.INITIALIZED; - } - - // "STOPPED" is not used in Eagle, so just do nothing. - if (preStatus != currentStatus) { - LOG.info("Application {} status changed from {} to {}", applicationEntity.getAppId(), preStatus, currentStatus); - } - applicationEntity.setStatus(currentStatus); - applicationEntityService.update(applicationEntity); - } catch (RuntimeException e) { - LOG.error(e.getMessage(), e); - } - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/eagle/blob/6fd95d5c/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/spi/AbstractApplicationProvider.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/spi/AbstractApplicationProvider.java b/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/spi/AbstractApplicationProvider.java deleted file mode 100644 index e537643..0000000 --- a/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/spi/AbstractApplicationProvider.java +++ /dev/null @@ -1,150 +0,0 @@ -/* - * 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 - * <p/> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p/> - * 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.eagle.app.spi; - -import com.google.common.base.Preconditions; -import com.google.inject.AbstractModule; -import com.google.inject.Singleton; -import org.apache.eagle.alert.engine.coordinator.StreamDefinition; -import org.apache.eagle.app.Application; -import org.apache.eagle.app.service.ApplicationListener; -import org.apache.eagle.common.module.GlobalScope; -import org.apache.eagle.common.module.ModuleRegistry; -import org.apache.eagle.common.module.ModuleScope; -import org.apache.eagle.metadata.model.ApplicationDesc; -import org.apache.eagle.metadata.model.ApplicationDocs; -import org.apache.eagle.metadata.model.ApplicationEntity; -import org.apache.eagle.metadata.model.Configuration; -import org.apache.eagle.metadata.persistence.MetadataStore; -import org.apache.eagle.metadata.service.memory.MemoryMetadataStore; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import javax.xml.bind.JAXBException; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Optional; - -/** - * Describe Application metadata with XML descriptor configuration in path of: /META-INF/providers/${ApplicationProviderClassName}.xml. - */ -public abstract class AbstractApplicationProvider<T extends Application> implements ApplicationProvider<T> { - private static final Logger LOG = LoggerFactory.getLogger(AbstractApplicationProvider.class); - private final ApplicationDesc applicationDesc; - - protected AbstractApplicationProvider() { - applicationDesc = new ApplicationXMLDescriptorLoader(this.getClass(),this.getApplicationClass()).getApplicationDesc(); - } - - protected void setVersion(String version) { - applicationDesc.setVersion(version); - } - - protected void setName(String name) { - applicationDesc.setName(name); - } - - protected void setAppClass(Class<T> appClass) { - applicationDesc.setAppClass(appClass); - } - - protected void setViewPath(String viewPath) { - applicationDesc.setViewPath(viewPath); - } - - protected void setConfiguration(Configuration configuration) { - applicationDesc.setConfiguration(configuration); - } - - protected void setAppConfig(String resourceName) { - try { - applicationDesc.setConfiguration(Configuration.fromResource(resourceName)); - } catch (JAXBException e) { - LOG.error("Failed to load configuration template from " + resourceName, e); - throw new RuntimeException("Failed to load configuration template from " + resourceName, e); - } - } - - @Override - public String toString() { - return String.format( - "%s[name=%s, type=%s, version=%s, viewPath=%s, appClass=%s, configuration= %s properties]", getClass().getSimpleName(), - applicationDesc.getName(), applicationDesc.getType(), applicationDesc.getVersion(), applicationDesc.getViewPath(), applicationDesc.getAppClass(), - applicationDesc.getConfiguration() == null ? 0 : applicationDesc.getConfiguration().size() - ); - } - - protected void setStreams(List<StreamDefinition> streams) { - applicationDesc.setStreams(streams); - } - - - protected void setDocs(ApplicationDocs docs) { - applicationDesc.setDocs(docs); - } - - public void setType(String type) { - applicationDesc.setType(type); - } - - @Override - public ApplicationDesc getApplicationDesc() { - return applicationDesc; - } - - private ModuleRegistry currentRegistry; - - @Override - public final void register(ModuleRegistry registry) { - LOG.debug("Registering modules {}", this.getClass().getName()); - this.currentRegistry = registry; - onRegister(); - } - - @Override - public Optional<ApplicationListener> getApplicationListener() { - return Optional.empty(); - } - - protected void onRegister() { - // Do nothing by default; - } - - protected <M extends ModuleScope,T> void bind(Class<M> scope, Class<T> type, Class<? extends T> impl) { - Preconditions.checkNotNull(currentRegistry, "No registry set before being used"); - currentRegistry.register(scope, new AbstractModule() { - @Override - protected void configure() { - bind(type).to(impl).in(Singleton.class); - } - }); - } - - public <T> void bind(Class<T> type, Class<? extends T> impl) { - bind(GlobalScope.class,type,impl); - } - - protected <M extends MetadataStore,T> void bindToMetaStore(Class<? extends M> scope, Class<T> type, Class<? extends T> impl) { - bind(scope,type,impl); - } - - public <T> void bindToMemoryMetaStore(Class<T> type, Class<? extends T> impl) { - bindToMetaStore(MemoryMetadataStore.class,type,impl); - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/eagle/blob/6fd95d5c/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/spi/ApplicationDescLoader.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/spi/ApplicationDescLoader.java b/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/spi/ApplicationDescLoader.java deleted file mode 100644 index ecab289..0000000 --- a/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/spi/ApplicationDescLoader.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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 - * <p> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p> - * 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.eagle.app.spi; - -import org.apache.eagle.metadata.model.ApplicationDesc; - -public interface ApplicationDescLoader { - - /** - * @return ApplicationDesc instance. - */ - ApplicationDesc getApplicationDesc(); -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/eagle/blob/6fd95d5c/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/spi/ApplicationProvider.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/spi/ApplicationProvider.java b/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/spi/ApplicationProvider.java deleted file mode 100644 index 0172498..0000000 --- a/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/spi/ApplicationProvider.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * 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 - * <p/> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p/> - * 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.eagle.app.spi; - -import com.codahale.metrics.health.HealthCheck; -import com.google.common.util.concurrent.Service; -import com.typesafe.config.Config; -import org.apache.eagle.app.Application; -import org.apache.eagle.app.service.ApplicationListener; -import org.apache.eagle.common.module.ModuleRegistry; -import org.apache.eagle.metadata.model.ApplicationDesc; - -import java.lang.reflect.ParameterizedType; -import java.util.List; -import java.util.Optional; - -/** - * Application Service Provider Interface (SPI) - * - * @param <T> Application Type. - */ -public interface ApplicationProvider<T extends Application> { - - /** - * @return application descriptor. - */ - ApplicationDesc getApplicationDesc(); - - /** - * Get Application Instance Type, by default load from generic parameter automatically - * - * @return application class type if exists. - */ - default Class<T> getApplicationClass() { - try { - String className = ((ParameterizedType) getClass().getGenericSuperclass()).getActualTypeArguments()[0].getTypeName(); - Class<?> clazz = Class.forName(className); - return (Class<T>) clazz; - } catch (Exception e) { - throw new IllegalStateException( - "Unable to get generic application class, " - + "reason: class is not parametrized with generic type, " - + "please provide application class by overriding getApplicationClass()"); - } - } - - /** - * @return application instance. - */ - T getApplication(); - - /** - * @return application lifecycle listeners type. - */ - Optional<ApplicationListener> getApplicationListener(); - - /** - * Extend application modules like Web Resource, Metadata Store, etc. - */ - void register(ModuleRegistry registry); - - /** - * @param config application config. - * @return Application-specific managed health check. - */ - default Optional<HealthCheck> getManagedHealthCheck(Config config) { - return Optional.empty(); - } - - /** - * - * @param envConfig server environment config. - * @return Server-level shared services. - */ - default Optional<List<Service>> getSharedServices(Config envConfig) { - return Optional.empty(); - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/eagle/blob/6fd95d5c/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/spi/ApplicationXMLDescriptorLoader.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/spi/ApplicationXMLDescriptorLoader.java b/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/spi/ApplicationXMLDescriptorLoader.java deleted file mode 100644 index 84768ae..0000000 --- a/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/spi/ApplicationXMLDescriptorLoader.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * 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 - * <p> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p> - * 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.eagle.app.spi; - -import org.apache.eagle.app.Application; -import org.apache.eagle.app.config.ApplicationProviderDescConfig; -import org.apache.eagle.app.utils.DynamicJarPathFinder; -import org.apache.eagle.metadata.model.ApplicationDesc; - -/** - * Describe Application metadata with XML descriptor configuration in path of: /META-INF/providers/${ApplicationProviderClassName}.xml - */ -class ApplicationXMLDescriptorLoader implements ApplicationDescLoader { - private final Class<? extends ApplicationProvider> providerClass; - private final Class<? extends Application> applicationClass; - - private static final String METADATA_RESOURCE_PATH = "/META-INF/providers/%s.xml"; - - ApplicationXMLDescriptorLoader(Class<? extends ApplicationProvider> providerClass, Class<? extends Application> applicationClass) { - this.providerClass = providerClass; - this.applicationClass = applicationClass; - } - - /** - * Default metadata path is: /META-INF/providers/${ApplicationProviderClassName}.xml - * <p>You are not recommended to override this method except you could make sure the path is universal unique</p> - * - * @return metadata file path - */ - private String generateXMLDescriptorPath() { - return String.format(METADATA_RESOURCE_PATH, providerClass.getName()); - } - - @Override - public ApplicationDesc getApplicationDesc() { - String descriptorPath = generateXMLDescriptorPath(); - ApplicationDesc applicationDesc = new ApplicationDesc(); - applicationDesc.setProviderClass(this.providerClass); - ApplicationProviderDescConfig descWrapperConfig = ApplicationProviderDescConfig.loadFromXML(this.getClass(), descriptorPath); - applicationDesc.setType(descWrapperConfig.getType()); - applicationDesc.setVersion(descWrapperConfig.getVersion()); - applicationDesc.setName(descWrapperConfig.getName()); - applicationDesc.setDocs(descWrapperConfig.getDocs()); - applicationDesc.setJarPath(DynamicJarPathFinder.findPath(applicationClass)); - if (applicationClass != null) { - applicationDesc.setAppClass(applicationClass); - if (!Application.class.isAssignableFrom(applicationDesc.getAppClass())) { - throw new IllegalStateException(applicationDesc.getAppClass() + " is not sub-class of " + Application.class.getCanonicalName()); - } - } - applicationDesc.setDependencies(descWrapperConfig.getDependencies()); - applicationDesc.setViewPath(descWrapperConfig.getViewPath()); - applicationDesc.setConfiguration(descWrapperConfig.getConfiguration()); - applicationDesc.setStreams(descWrapperConfig.getStreams()); - return applicationDesc; - } -} http://git-wip-us.apache.org/repos/asf/eagle/blob/6fd95d5c/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/test/ApplicationSimulator.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/test/ApplicationSimulator.java b/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/test/ApplicationSimulator.java deleted file mode 100644 index d8f342f..0000000 --- a/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/test/ApplicationSimulator.java +++ /dev/null @@ -1,52 +0,0 @@ -/** - * 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 - * <p/> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p/> - * 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.eagle.app.test; - -import org.apache.eagle.app.spi.ApplicationProvider; -import com.google.inject.Guice; -import com.google.inject.Module; - -import java.util.Arrays; -import java.util.List; -import java.util.Map; - -/** - * Application test simulator for developer to quickly run application without diving into application lifecycle. - */ -public abstract class ApplicationSimulator { - public abstract void start(String appType); - - public abstract void start(String appType, Map<String, Object> appConfig); - - public abstract void start(Class<? extends ApplicationProvider> appProviderClass); - - public abstract void start(Class<? extends ApplicationProvider> appProviderClass, Map<String, Object> appConfig) throws Exception; - - public static ApplicationSimulator getInstance() { - return Guice.createInjector(new ApplicationTestGuiceModule()).getInstance(ApplicationSimulator.class); - } - - /** - * @param modules additional modules. - * @return ApplicationSimulator instance. - */ - public static ApplicationSimulator getInstance(Module... modules) { - List<Module> contextModules = Arrays.asList(modules); - contextModules.add(new ApplicationTestGuiceModule()); - return Guice.createInjector(contextModules).getInstance(ApplicationSimulator.class); - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/eagle/blob/6fd95d5c/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/test/ApplicationSimulatorImpl.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/test/ApplicationSimulatorImpl.java b/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/test/ApplicationSimulatorImpl.java deleted file mode 100644 index b10205f..0000000 --- a/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/test/ApplicationSimulatorImpl.java +++ /dev/null @@ -1,121 +0,0 @@ -/* - * 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 - * <p/> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p/> - * 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.eagle.app.test; - -import com.google.inject.Inject; -import com.typesafe.config.Config; -import org.apache.eagle.app.resource.ApplicationResource; -import org.apache.eagle.app.service.ApplicationOperations; -import org.apache.eagle.app.spi.ApplicationProvider; -import org.apache.eagle.metadata.model.ApplicationEntity; -import org.apache.eagle.metadata.model.SiteEntity; -import org.apache.eagle.metadata.resource.SiteResource; -import org.apache.eagle.metadata.service.ApplicationStatusUpdateService; -import org.junit.Assert; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.HashMap; -import java.util.Map; -import java.util.concurrent.Semaphore; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicInteger; - -public class ApplicationSimulatorImpl extends ApplicationSimulator { - private static final Logger LOG = LoggerFactory.getLogger(ApplicationSimulatorImpl.class); - - private final Config config; - private final SiteResource siteResource; - private final ApplicationResource applicationResource; - - @Inject - ApplicationStatusUpdateService statusUpdateService; - - @Inject - public ApplicationSimulatorImpl(Config config, SiteResource siteResource, ApplicationResource applicationResource) { - this.config = config; - this.siteResource = siteResource; - this.applicationResource = applicationResource; - } - - private static final AtomicInteger incr = new AtomicInteger(); - - private SiteEntity getUniqueSite() { - // Create local site - SiteEntity siteEntity = new SiteEntity(); - siteEntity.setSiteId("SIMULATED_SITE_" + incr.incrementAndGet()); - siteEntity.setSiteName(siteEntity.getSiteId()); - siteEntity.setDescription("Automatically generated unique simulation site " + siteEntity.getSiteId() + " (simulator: " + this + ")"); - return siteEntity; - } - - @Override - public void start(String appType) { - start(appType, new HashMap<>()); - } - - @Override - public void start(String appType, Map<String, Object> appConfig) { - SiteEntity siteEntity = getUniqueSite(); - siteResource.createSite(siteEntity); - Assert.assertNotNull(siteEntity.getUuid()); - ApplicationOperations.InstallOperation installOperation = new ApplicationOperations.InstallOperation(siteEntity.getSiteId(), appType, ApplicationEntity.Mode.LOCAL); - installOperation.setConfiguration(appConfig); - // Install application - ApplicationEntity applicationEntity = applicationResource.installApplication(installOperation).getData(); - // Start application - applicationResource.startApplication(new ApplicationOperations.StartOperation(applicationEntity.getUuid())); - statusUpdateService.updateApplicationEntityStatus(applicationEntity); - Semaphore semp = new Semaphore(1); - Thread stopThread = new Thread(() -> { - applicationResource.stopApplication(new ApplicationOperations.StopOperation(applicationEntity.getUuid())); - while (applicationEntity.getStatus() != ApplicationEntity.Status.INITIALIZED - && applicationEntity.getStatus() != ApplicationEntity.Status.STOPPED) { - statusUpdateService.updateApplicationEntityStatus(applicationEntity); - try { - Thread.sleep(1000); - } catch (Exception e) { - LOG.warn("{}", e); - } - } - semp.release(); - }); - stopThread.start(); - try { - stopThread.join(60000L); - semp.tryAcquire(60, TimeUnit.SECONDS); - applicationResource.uninstallApplication(new ApplicationOperations.UninstallOperation(applicationEntity.getUuid())); - } catch (Exception e) { - throw new IllegalStateException("Application status didn't become STOPPED"); - } - } - - @Override - public void start(Class<? extends ApplicationProvider> appProviderClass) { - start(appProviderClass, new HashMap<>()); - } - - @Override - public void start(Class<? extends ApplicationProvider> appProviderClass, Map<String, Object> appConfig) { - try { - ApplicationProvider applicationProvider = appProviderClass.newInstance(); - start(applicationProvider.getApplicationDesc().getType(), appConfig); - } catch (InstantiationException | IllegalAccessException e) { - throw new IllegalStateException(e.getMessage(), e); - } - } -} http://git-wip-us.apache.org/repos/asf/eagle/blob/6fd95d5c/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/test/ApplicationTestBase.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/test/ApplicationTestBase.java b/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/test/ApplicationTestBase.java deleted file mode 100644 index e93df64..0000000 --- a/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/test/ApplicationTestBase.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * 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 - * <p/> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p/> - * 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.eagle.app.test; - -import com.google.inject.Guice; -import com.google.inject.Inject; -import com.google.inject.Injector; -import org.apache.eagle.metadata.model.ApplicationEntity; -import org.apache.eagle.metadata.service.ApplicationStatusUpdateService; -import org.junit.Assert; -import org.junit.Before; - -public class ApplicationTestBase { - private Injector injector; - - - @Inject - ApplicationStatusUpdateService statusUpdateService; - - @Before - public void setUp() { - injector = Guice.createInjector(new ApplicationTestGuiceModule()); - injector.injectMembers(this); - } - - protected Injector injector() { - return injector; - } - - protected void awaitApplicationStop(ApplicationEntity applicationEntity) throws InterruptedException { - int attempt = 0; - while (attempt < 30) { - attempt ++; - if (applicationEntity.getStatus() == ApplicationEntity.Status.STOPPED - || applicationEntity.getStatus() == ApplicationEntity.Status.INITIALIZED) { - break; - } else { - statusUpdateService.updateApplicationEntityStatus(applicationEntity); - Thread.sleep(1000); - } - } - if (attempt >= 30) { - Assert.fail("Failed to wait for application to STOPPED after 10 attempts"); - } - } - - protected void awaitApplicationStatus(ApplicationEntity applicationEntity, ApplicationEntity.Status status) throws InterruptedException { - int attempt = 0; - while (attempt < 30) { - attempt ++; - if (applicationEntity.getStatus() == status) { - break; - } else { - statusUpdateService.updateApplicationEntityStatus(applicationEntity); - Thread.sleep(1000); - } - } - if (attempt >= 30) { - Assert.fail("Failed to wait for application to STOPPED after 10 attempts"); - } - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/eagle/blob/6fd95d5c/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/test/ApplicationTestGuiceModule.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/test/ApplicationTestGuiceModule.java b/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/test/ApplicationTestGuiceModule.java deleted file mode 100644 index 3e2ba2c..0000000 --- a/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/test/ApplicationTestGuiceModule.java +++ /dev/null @@ -1,46 +0,0 @@ -/** - * 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 - * <p/> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p/> - * 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.eagle.app.test; - -import org.apache.eagle.app.module.ApplicationExtensionLoader; -import org.apache.eagle.app.module.ApplicationGuiceModule; -import org.apache.eagle.app.service.ApplicationProviderService; -import org.apache.eagle.app.service.impl.ApplicationProviderServiceImpl; -import org.apache.eagle.common.module.CommonGuiceModule; -import org.apache.eagle.common.module.GlobalScope; -import org.apache.eagle.common.module.ModuleRegistry; -import org.apache.eagle.metadata.service.memory.MemoryMetadataStore; -import com.google.inject.AbstractModule; -import com.google.inject.Singleton; -import com.typesafe.config.ConfigFactory; - -public class ApplicationTestGuiceModule extends AbstractModule { - @Override - protected void configure() { - CommonGuiceModule common = new CommonGuiceModule(); - ApplicationProviderService instance = new ApplicationProviderServiceImpl(ConfigFactory.load()); - ApplicationGuiceModule app = new ApplicationGuiceModule(instance); - MemoryMetadataStore store = new MemoryMetadataStore(); - install(common); - install(app); - install(store); - ModuleRegistry registry = ApplicationExtensionLoader.load(common, app, store); - registry.getModules(store.getClass()).forEach(this::install); - registry.getModules(GlobalScope.class).forEach(this::install); - bind(ApplicationSimulator.class).to(ApplicationSimulatorImpl.class).in(Singleton.class); - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/eagle/blob/6fd95d5c/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/test/KafkaTestServer.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/test/KafkaTestServer.java b/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/test/KafkaTestServer.java deleted file mode 100644 index 9744350..0000000 --- a/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/test/KafkaTestServer.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * 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 - * <p> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p> - * 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.eagle.app.test; - -import java.io.File; -import java.io.IOException; - -public interface KafkaTestServer { - void start() throws Exception; - - void stop() throws IOException; - - int getZookeeperPort(); - - int getKafkaBrokerPort(); - - static KafkaTestServer create(File logDir) { - return new KafkaTestServerImpl(logDir); - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/eagle/blob/6fd95d5c/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/test/KafkaTestServerImpl.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/test/KafkaTestServerImpl.java b/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/test/KafkaTestServerImpl.java deleted file mode 100644 index 30ce67c..0000000 --- a/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/test/KafkaTestServerImpl.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * 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 - * <p> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p> - * 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.eagle.app.test; - -import kafka.server.KafkaConfig; -import kafka.server.KafkaServerStartable; -import org.apache.curator.framework.CuratorFramework; -import org.apache.curator.framework.CuratorFrameworkFactory; -import org.apache.curator.retry.ExponentialBackoffRetry; -import org.apache.curator.test.InstanceSpec; -import org.apache.curator.test.TestingServer; - -import java.io.File; -import java.io.IOException; -import java.util.Properties; - -class KafkaTestServerImpl implements KafkaTestServer { - - private final File logDir; - private TestingServer zkServer; - private CuratorFramework curatorClient; - private KafkaServerStartable kafkaServer; - private int kafkaPort = InstanceSpec.getRandomPort(); - private int zookeeperPort = InstanceSpec.getRandomPort(); - - public KafkaTestServerImpl(File logDir) { - this.logDir = logDir; - } - - @Override - public void start() throws Exception { - zkServer = new TestingServer(zookeeperPort, logDir); - ExponentialBackoffRetry retryPolicy = new ExponentialBackoffRetry(1000, 3); - curatorClient = CuratorFrameworkFactory.newClient(zkServer.getConnectString(), retryPolicy); - curatorClient.start(); - - Properties props = new Properties(); - - props.setProperty("zookeeper.connect", zkServer.getConnectString()); - props.setProperty("broker.id", "0"); - props.setProperty("port", "" + kafkaPort); - props.setProperty("log.dirs", logDir.getAbsolutePath()); - props.setProperty("auto.create.topics.enable", "true"); - - kafkaServer = new KafkaServerStartable(new KafkaConfig(props)); - kafkaServer.startup(); - } - - @Override - public void stop() throws IOException { - kafkaServer.shutdown(); - curatorClient.close(); - zkServer.close(); - } - - @Override - public int getZookeeperPort() { - return this.zookeeperPort; - } - - @Override - public int getKafkaBrokerPort() { - return this.kafkaPort; - } -} http://git-wip-us.apache.org/repos/asf/eagle/blob/6fd95d5c/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/test/package-info.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/test/package-info.java b/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/test/package-info.java deleted file mode 100644 index aaaf157..0000000 --- a/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/test/package-info.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * 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 - * <p/> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p/> - * 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. - * - * - * - */ - -/** - * <h1>How to test application ?</h1> - * - * <h2>Option 1: Test with AppTestRunner</h2> - * <pre> - * @RunWith(AppTestRunner.class) - * public class ExampleApplicationTest { - * @Inject - * private ApplicationResource applicationResource; - * } - * </pre> - * - * <h2>Option 2: Manually create injector</h2> - * <pre> - * public class ExampleApplicationTest { - * @Inject - * private ApplicationResource applicationResource; - * - * @Before - * public void setUp(){ - * Guice.createInjector(new AppTestModule()).injector.injectMembers(this); - * } - * } - * </pre> - */ -package org.apache.eagle.app.test; \ No newline at end of file http://git-wip-us.apache.org/repos/asf/eagle/blob/6fd95d5c/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/utils/AppConfigUtils.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/utils/AppConfigUtils.java b/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/utils/AppConfigUtils.java deleted file mode 100644 index 7bad0bd..0000000 --- a/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/utils/AppConfigUtils.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * 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 - * <p/> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p/> - * 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.eagle.app.utils; - -import com.typesafe.config.Config; - -public class AppConfigUtils { - public static String getSiteId(Config config) { - return config.getString("siteId"); - } - - public static String getAppId(Config config) { - return config.getString("appId"); - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/eagle/blob/6fd95d5c/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/utils/ApplicationConfigHelper.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/utils/ApplicationConfigHelper.java b/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/utils/ApplicationConfigHelper.java deleted file mode 100644 index f034e92..0000000 --- a/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/utils/ApplicationConfigHelper.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * 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 - * <p/> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p/> - * 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.eagle.app.utils; - -import com.fasterxml.jackson.databind.ObjectMapper; -import com.typesafe.config.Config; - -import java.util.Map; - -//public class ApplicationConfigHelper { -// private static final ObjectMapper mapper = new ObjectMapper(); -// public static <Conf extends Configuration> Conf convertFrom(Map<String,Object> configMap, Class<Conf> confClass){ -// return mapper.convertValue(configMap,confClass); -// } -// -// /** -// * Map application configuration from environment -// * -// * @param config -// * @return -// */ -// public static Map<String,Object> unwrapFrom(Config config, String namespace){ -// if(config.hasPath(namespace)) { -// return config.getConfig(namespace).root().unwrapped(); -// }else{ -// Map<String,Object> unwrappedConfig = config.root().unwrapped(); -// if(unwrappedConfig.containsKey(namespace)){ -// return (Map<String,Object>) unwrappedConfig.get(namespace); -// }else { -// throw new IllegalArgumentException("Failed to load app config as config key: '"+namespace+"' was not found in: "+config); -// } -// } -// } -//} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/eagle/blob/6fd95d5c/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/utils/ApplicationExecutionConfig.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/utils/ApplicationExecutionConfig.java b/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/utils/ApplicationExecutionConfig.java deleted file mode 100644 index 73199fe..0000000 --- a/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/utils/ApplicationExecutionConfig.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * 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 - * <p/> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p/> - * 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.eagle.app.utils; - -import com.typesafe.config.Config; -import org.apache.eagle.metadata.model.ApplicationEntity; - -/** - * Application Execution Must-have base configuration. - */ -public class ApplicationExecutionConfig { - public static final String APP_ID_KEY = "appId"; - public static final String MODE_KEY = "mode"; - public static final String SITE_ID_KEY = "siteId"; - public static final String JAR_PATH_KEY = "jarPath"; - - private final String siteId; - private final String mode; - private final String appId; - private final String jarPath; - - public ApplicationExecutionConfig(ApplicationEntity metadata) { - this.siteId = metadata.getSite().getSiteId(); - this.mode = metadata.getMode().name(); - this.appId = metadata.getAppId(); - this.jarPath = metadata.getJarPath(); - } - - public ApplicationExecutionConfig(Config config) { - this.siteId = config.getString(SITE_ID_KEY); - this.mode = config.getString(MODE_KEY); - this.appId = config.getString(APP_ID_KEY); - this.jarPath = config.getString(JAR_PATH_KEY); - } - - public String getJarPath() { - return jarPath; - } - - public String getAppId() { - return appId; - } - - public String getMode() { - return mode; - } - - public String getSiteId() { - return siteId; - } -} http://git-wip-us.apache.org/repos/asf/eagle/blob/6fd95d5c/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/utils/Clock.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/utils/Clock.java b/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/utils/Clock.java deleted file mode 100644 index f3deff9..0000000 --- a/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/utils/Clock.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * 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 - * <p/> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p/> - * 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.eagle.app.utils; - -public interface Clock { - Clock WALL = System::currentTimeMillis; - - long now(); -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/eagle/blob/6fd95d5c/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/utils/ClockWithOffset.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/utils/ClockWithOffset.java b/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/utils/ClockWithOffset.java deleted file mode 100644 index 62b060f..0000000 --- a/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/utils/ClockWithOffset.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * 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 - * <p/> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p/> - * 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.eagle.app.utils; - -public enum ClockWithOffset implements Clock { - INSTANCE; - - private volatile long offset = 0L; - - public void setOffset(long offset) { - if (offset >= 0) { - this.offset = offset; - } - } - - @Override - public long now() { - return offset + System.currentTimeMillis(); - } -} http://git-wip-us.apache.org/repos/asf/eagle/blob/6fd95d5c/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/utils/DynamicJarPathFinder.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/utils/DynamicJarPathFinder.java b/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/utils/DynamicJarPathFinder.java deleted file mode 100644 index 5e20b25..0000000 --- a/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/utils/DynamicJarPathFinder.java +++ /dev/null @@ -1,130 +0,0 @@ -/* - * 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 - * <p/> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p/> - * 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.eagle.app.utils; - - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.File; -import java.io.UnsupportedEncodingException; -import java.net.URLDecoder; -import java.nio.charset.Charset; - -/** - * http://stackoverflow.com/questions/1983839/determine-which-jar-file-a-class-is-from - * https://github.com/rzwitserloot/lombok.patcher/blob/master/src/lombok/patcher/inject/LiveInjector.java - */ -public class DynamicJarPathFinder { - private static final Logger LOG = LoggerFactory.getLogger(DynamicJarPathFinder.class); - - /** - * If the provided class has been loaded from a jar file that is on the local file system, will find the absolute path to that jar file. - * - * @param context The jar file that contained the class file that represents this class will be found. Specify {@code null} to let {@code LiveInjector} - * find its own jar. - * @throws IllegalStateException If the specified class was loaded from a directory or in some other way (such as via HTTP, from a database, or some - * other custom classloading device). - */ - public static String findPathJar(Class<?> context) throws IllegalStateException { - if (context == null) { - context = DynamicJarPathFinder.class; - } - String rawName = context.getName(); - String classFileName; - /* rawName is something like package.name.ContainingClass$ClassName. We need to turn this into ContainingClass$ClassName.class. */ - { - int idx = rawName.lastIndexOf('.'); - classFileName = (idx == -1 ? rawName : rawName.substring(idx + 1)) + ".class"; - } - - String uri = context.getResource(classFileName).toString(); - if (uri.startsWith("file:")) { - throw new IllegalStateException("This class has been loaded from a directory and not from a jar file."); - } - if (!uri.startsWith("jar:file:")) { - int idx = uri.indexOf(':'); - String protocol = idx == -1 ? "(unknown)" : uri.substring(0, idx); - throw new IllegalStateException("This class has been loaded remotely via the " + protocol - + " protocol. Only loading from a jar on the local file system is supported."); - } - - int idx = uri.indexOf('!'); - //As far as I know, the if statement below can't ever trigger, so it's more of a sanity check thing. - if (idx == -1) { - throw new IllegalStateException("You appear to have loaded this class from a local jar file, but I can't make sense of the URL!"); - } - - try { - String fileName = URLDecoder.decode(uri.substring("jar:file:".length(), idx), Charset.defaultCharset().name()); - return new File(fileName).getAbsolutePath(); - } catch (UnsupportedEncodingException e) { - throw new InternalError("default charset doesn't exist. Your VM is borked."); - } - } - - /** - * Similar to JarPathFinder, but not make sure the path must valid jar. - * - * @return the class path contains the context class - * @see DynamicJarPathFinder#findPathJar(Class) - */ - public static String findPath(Class<?> context) throws IllegalStateException { - if (context == null) { - context = DynamicJarPathFinder.class; - } - String rawName = context.getName(); - String classFileName; - /* rawName is something like package.name.ContainingClass$ClassName. We need to turn this into ContainingClass$ClassName.class. */ - { - int idx = rawName.lastIndexOf('.'); - classFileName = (idx == -1 ? rawName : rawName.substring(idx + 1)) + ".class"; - } - - String uri = context.getResource(classFileName).toString(); - if (uri.startsWith("file:")) { - LOG.warn("This class has been loaded from a directory and not from a jar file: {}", uri); - String fileName = null; - try { - fileName = URLDecoder.decode(uri.substring("file:".length(), uri.length()), Charset.defaultCharset().name()); - return new File(fileName).getAbsolutePath(); - } catch (UnsupportedEncodingException e) { - throw new InternalError("default charset doesn't exist. Your VM is borked."); - } - } - - if (!uri.startsWith("jar:file:")) { - int idx = uri.indexOf(':'); - String protocol = idx == -1 ? "(unknown)" : uri.substring(0, idx); - throw new IllegalStateException("This class has been loaded remotely via the " + protocol - + " protocol. Only loading from a jar on the local file system is supported."); - } - - int idx = uri.indexOf('!'); - //As far as I know, the if statement below can't ever trigger, so it's more of a sanity check thing. - if (idx == -1) { - throw new IllegalStateException("You appear to have loaded this class from a local jar file, but I can't make sense of the URL!"); - } - - try { - String fileName = URLDecoder.decode(uri.substring("jar:file:".length(), idx), Charset.defaultCharset().name()); - return new File(fileName).getAbsolutePath(); - } catch (UnsupportedEncodingException e) { - throw new InternalError("default charset doesn't exist. Your VM is borked."); - } - } -} http://git-wip-us.apache.org/repos/asf/eagle/blob/6fd95d5c/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/utils/ManualClock.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/utils/ManualClock.java b/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/utils/ManualClock.java deleted file mode 100644 index cd8fc80..0000000 --- a/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/utils/ManualClock.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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 - * <p/> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p/> - * 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.eagle.app.utils; - -import java.util.concurrent.atomic.AtomicLong; - -public class ManualClock implements Clock { - - private final AtomicLong time; - - public ManualClock(long init) { - time = new AtomicLong(init); - } - - public void set(long t) { - time.set(t); - } - - public long now() { - return time.get(); - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - - ManualClock clock = (ManualClock) o; - return now() == clock.now(); - } - - @Override - public int hashCode() { - return Long.valueOf(now()).hashCode(); - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/eagle/blob/6fd95d5c/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/utils/StreamConvertHelper.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/utils/StreamConvertHelper.java b/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/utils/StreamConvertHelper.java deleted file mode 100644 index c25a93b..0000000 --- a/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/utils/StreamConvertHelper.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * 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 - * <p> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p> - * 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.eagle.app.utils; - -import backtype.storm.tuple.Tuple; -import org.apache.eagle.common.utils.Tuple2; - -import java.util.HashMap; -import java.util.Map; - -public class StreamConvertHelper { - private static Map tupleToMap(Tuple tuple) { - Map values = new HashMap<>(); - for (String field : tuple.getFields()) { - values.put(field, tuple.getValueByField(field)); - } - return values; - } - - public static Tuple2<Object,Map> tupleToEvent(Tuple input) { - Map event = null; - Object key = input.getValue(0); - if (input.size() < 2) { - event = StreamConvertHelper.tupleToMap(input); - } else { - Object value = input.getValue(1); - if (value != null) { - if (value instanceof Map) { - event = (Map) input.getValue(1); - } else { - event = StreamConvertHelper.tupleToMap(input); - } - } - } - return new Tuple2<>(key, event); - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/eagle/blob/6fd95d5c/eagle-core/eagle-app/eagle-app-base/src/main/resources/HealthCheckTemplate.vm ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-app/eagle-app-base/src/main/resources/HealthCheckTemplate.vm b/eagle-core/eagle-app/eagle-app-base/src/main/resources/HealthCheckTemplate.vm deleted file mode 100644 index 5a92bb7..0000000 --- a/eagle-core/eagle-app/eagle-app-base/src/main/resources/HealthCheckTemplate.vm +++ /dev/null @@ -1,43 +0,0 @@ -<!-- - ~ 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. - --> -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml"> -<head> - <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> - <meta name="viewport" content="width=device-width"/> -</head> -<body> - #set ( $elem = $unHealthyContext ) - -<table border="1"> - <tr> - <th><b>Application ID</b></th> - <td><b>Health Check Message</b></td> - </tr> - #foreach($appId in ${elem["appMsgs"].keySet()}) - <tr> - <th>$appId</th> - <td>${elem["appMsgs"].get($appId)}</td> - </tr> - #end -</table> - -<p><b>Health Check: </b><a href=$elem["healthCheckUrl"]>$elem["healthCheckUrl"]</a></p> -<p><b>Appliaction Management: </b><a href=$elem["appMgmtUrl"]>$elem["appMgmtUrl"]</a></p> - -</body> -</html> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/eagle/blob/6fd95d5c/eagle-core/eagle-app/eagle-app-base/src/main/resources/log4j.properties ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-app/eagle-app-base/src/main/resources/log4j.properties b/eagle-core/eagle-app/eagle-app-base/src/main/resources/log4j.properties deleted file mode 100644 index d59ded6..0000000 --- a/eagle-core/eagle-app/eagle-app-base/src/main/resources/log4j.properties +++ /dev/null @@ -1,21 +0,0 @@ -# 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. - -log4j.rootLogger=INFO, stdout - -# standard output -log4j.appender.stdout=org.apache.log4j.ConsoleAppender -log4j.appender.stdout.layout=org.apache.log4j.PatternLayout -log4j.appender.stdout.layout.ConversionPattern=%d{ISO8601} %p [%t] %c{2}[%L]: %m%n \ No newline at end of file http://git-wip-us.apache.org/repos/asf/eagle/blob/6fd95d5c/eagle-core/eagle-app/eagle-app-base/src/test/java/org/apache/eagle/app/ApplicationProviderDescConfigTest.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-app/eagle-app-base/src/test/java/org/apache/eagle/app/ApplicationProviderDescConfigTest.java b/eagle-core/eagle-app/eagle-app-base/src/test/java/org/apache/eagle/app/ApplicationProviderDescConfigTest.java deleted file mode 100644 index 992c622..0000000 --- a/eagle-core/eagle-app/eagle-app-base/src/test/java/org/apache/eagle/app/ApplicationProviderDescConfigTest.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * 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 - * <p> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p> - * 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.eagle.app; - -import org.junit.Assert; -import org.junit.Test; - -import javax.xml.bind.JAXBContext; -import javax.xml.bind.Unmarshaller; -import java.io.InputStream; - - -public class ApplicationProviderDescConfigTest { - - @Test - public void testStreamDefinitionLoadFromXML(){ - String configXmlFile = "TestStreamDefinitionConf.xml"; - try { - JAXBContext jc = JAXBContext.newInstance(StreamDefinitions.class); - Unmarshaller unmarshaller = jc.createUnmarshaller(); - InputStream is = ApplicationProviderDescConfigTest.class.getResourceAsStream(configXmlFile); - if(is == null){ - is = ApplicationProviderDescConfigTest.class.getResourceAsStream("/"+configXmlFile); - } - if(is == null){ - throw new IllegalStateException("Stream Definition configuration "+configXmlFile+" is not found"); - } - StreamDefinitions streamDefinitions = (StreamDefinitions) unmarshaller.unmarshal(is); - Assert.assertNotNull(streamDefinitions); - } catch (Exception ex){ - throw new RuntimeException("Failed to load application descriptor configuration: "+configXmlFile,ex); - } - } -} http://git-wip-us.apache.org/repos/asf/eagle/blob/6fd95d5c/eagle-core/eagle-app/eagle-app-base/src/test/java/org/apache/eagle/app/ApplicationProviderServiceTest.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-app/eagle-app-base/src/test/java/org/apache/eagle/app/ApplicationProviderServiceTest.java b/eagle-core/eagle-app/eagle-app-base/src/test/java/org/apache/eagle/app/ApplicationProviderServiceTest.java deleted file mode 100644 index 4f555bb..0000000 --- a/eagle-core/eagle-app/eagle-app-base/src/test/java/org/apache/eagle/app/ApplicationProviderServiceTest.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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 - * <p/> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p/> - * 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.eagle.app; - -import static org.junit.Assert.*; - -import com.google.inject.Inject; -import org.apache.eagle.app.service.ApplicationProviderService; -import org.apache.eagle.app.spi.ApplicationProvider; -import org.apache.eagle.app.test.ApplicationTestBase; -import org.apache.eagle.common.Version; -import org.apache.eagle.metadata.model.ApplicationDesc; -import org.junit.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.Collection; - -public class ApplicationProviderServiceTest extends ApplicationTestBase { - private final static Logger LOGGER = LoggerFactory.getLogger(ApplicationProviderServiceTest.class); - - @Inject - private - ApplicationProviderService providerManager; - - @Test - public void testApplicationProviderLoaderService(){ - Collection<ApplicationDesc> applicationDescs = providerManager.getApplicationDescs(); - Collection<ApplicationProvider> applicationProviders = providerManager.getProviders(); - applicationDescs.forEach((d)-> LOGGER.debug(d.toString())); - applicationProviders.forEach((d)-> LOGGER.debug(d.toString())); - assertNull(providerManager.getApplicationDescByType("TEST_APPLICATION").getViewPath()); - assertEquals(Version.version,providerManager.getApplicationDescByType("TEST_APPLICATION").getVersion()); - assertEquals("/apps/test_web_app",providerManager.getApplicationDescByType("TEST_WEB_APPLICATION").getViewPath()); - assertEquals("0.5.0-beta",providerManager.getApplicationDescByType("TEST_WEB_APPLICATION").getVersion()); - assertNotNull(providerManager.getApplicationDescByType("TEST_WEB_APPLICATION").getDependencies()); - assertEquals(1,providerManager.getApplicationDescByType("TEST_WEB_APPLICATION").getDependencies().size()); - assertEquals("TEST_APPLICATION",providerManager.getApplicationDescByType("TEST_WEB_APPLICATION").getDependencies().get(0).getType()); - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/eagle/blob/6fd95d5c/eagle-core/eagle-app/eagle-app-base/src/test/java/org/apache/eagle/app/ConfigurationHelperTest.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-app/eagle-app-base/src/test/java/org/apache/eagle/app/ConfigurationHelperTest.java b/eagle-core/eagle-app/eagle-app-base/src/test/java/org/apache/eagle/app/ConfigurationHelperTest.java deleted file mode 100644 index ebdae61..0000000 --- a/eagle-core/eagle-app/eagle-app-base/src/test/java/org/apache/eagle/app/ConfigurationHelperTest.java +++ /dev/null @@ -1,33 +0,0 @@ -/** - * 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 - * <p/> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p/> - * 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.eagle.app; - -import org.apache.eagle.metadata.model.Configuration; -import org.apache.eagle.metadata.utils.ConfigTemplateHelper; -import org.junit.Assert; -import org.junit.Test; - -import javax.xml.bind.JAXBException; - -public class ConfigurationHelperTest { - @Test - public void testConfigTemplateUnmarshall() throws JAXBException { - Configuration configuration = ConfigTemplateHelper.unmarshallFromResource("/config_template.xml"); - Assert.assertNotNull(configuration); - } -} \ No newline at end of file
