brooklyn-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aledsage <...@git.apache.org>
Subject [GitHub] incubator-brooklyn pull request: System Service enricher
Date Wed, 18 Mar 2015 10:07:51 GMT
Github user aledsage commented on a diff in the pull request:

    https://github.com/apache/incubator-brooklyn/pull/556#discussion_r26650515
  
    --- Diff: software/base/src/main/java/brooklyn/entity/service/SystemServiceEnricher.java
---
    @@ -0,0 +1,152 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one
    + * or more contributor license agreements.  See the NOTICE file
    + * distributed with this work for additional information
    + * regarding copyright ownership.  The ASF licenses this file
    + * to you under the Apache License, Version 2.0 (the
    + * "License"); you may not use this file except in compliance
    + * with the License.  You may obtain a copy of the License at
    + *
    + *     http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing,
    + * software distributed under the License is distributed on an
    + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    + * KIND, either express or implied.  See the License for the
    + * specific language governing permissions and limitations
    + * under the License.
    + */
    +package brooklyn.entity.service;
    +
    +import java.util.Set;
    +
    +import brooklyn.config.ConfigKey;
    +import brooklyn.enricher.basic.AbstractEnricher;
    +import brooklyn.entity.Entity;
    +import brooklyn.entity.basic.Attributes;
    +import brooklyn.entity.basic.BrooklynTaskTags;
    +import brooklyn.entity.basic.BrooklynTaskTags.WrappedStream;
    +import brooklyn.entity.basic.ConfigKeys;
    +import brooklyn.entity.basic.Entities;
    +import brooklyn.entity.basic.EntityLocal;
    +import brooklyn.entity.basic.SoftwareProcess;
    +import brooklyn.entity.effector.EffectorTasks;
    +import brooklyn.location.basic.SshMachineLocation;
    +import brooklyn.management.ExecutionContext;
    +import brooklyn.management.Task;
    +import brooklyn.policy.Enricher;
    +import brooklyn.util.net.Urls;
    +import brooklyn.util.task.BasicExecutionManager;
    +import brooklyn.util.task.DynamicTasks;
    +import brooklyn.util.task.TaskBuilder;
    +import brooklyn.util.task.ssh.SshPutTaskWrapper;
    +import brooklyn.util.task.ssh.SshTasks;
    +import brooklyn.util.task.system.ProcessTaskFactory;
    +import brooklyn.util.task.system.ProcessTaskWrapper;
    +
    +import com.google.common.collect.ImmutableSet;
    +
    +public class SystemServiceEnricher extends AbstractEnricher implements Enricher {
    +    static final Set<String> LAUNCH_EFFECTOR_NAMES = ImmutableSet.of("start", "restart");
    +    public static final ConfigKey<String> LAUNCH_SCRIPT_NAME = ConfigKeys.newStringConfigKey(
    +            "service.script_name", "The name of the launch script to be created in the
runtime directory of the entity.", "service-launch.sh");
    +    public static final ConfigKey<String> SERVICE_NAME = ConfigKeys.newStringConfigKey(
    +            "service.name", "The name of the system service. Can use ${entity_name} and
${id} variables to template the value.", "${entity_name}-${id}");
    +
    +    @Override
    +    public void setEntity(EntityLocal entity) {
    +        super.setEntity(entity);
    +        subscribeLaunch();
    +    }
    +
    +    private void subscribeLaunch() {
    +        if(checkCanSubscribe()) {
    +            getSubscriptionTracker().subscribe(entity, Attributes.SERVICE_STATE_ACTUAL,
new EntityLaunchListener(this));
    --- End diff --
    
    Can just use `subscribe(...)` rather than `getSubscriptionTracker().subscribe(...)`


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message