brooklyn-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From geomacy <...@git.apache.org>
Subject [GitHub] incubator-brooklyn pull request: SimpleCommand addition to brookly...
Date Mon, 16 Nov 2015 10:25:38 GMT
Github user geomacy commented on a diff in the pull request:

    https://github.com/apache/incubator-brooklyn/pull/1030#discussion_r44907503
  
    --- Diff: usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/SimpleCommandSshDriver.java
---
    @@ -0,0 +1,192 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one
    + * or more contributor license agreements.  See the NOTICE file
    + * distributed with this work for additional information
    + * regarding copyright ownership.  The ASF licenses this file
    + * to you under the Apache License, Version 2.0 (the
    + * "License"); you may not use this file except in compliance
    + * with the License.  You may obtain a copy of the License at
    + *
    + *     http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing,
    + * software distributed under the License is distributed on an
    + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    + * KIND, either express or implied.  See the License for the
    + * specific language governing permissions and limitations
    + * under the License.
    + */
    +package org.apache.brooklyn.test.framework;
    +
    +import com.google.common.base.Joiner;
    +import com.google.common.base.Splitter;
    +import com.google.common.collect.ImmutableList;
    +import com.google.common.collect.ImmutableMap;
    +import org.apache.brooklyn.api.entity.EntityLocal;
    +import org.apache.brooklyn.api.location.Location;
    +import org.apache.brooklyn.api.mgmt.TaskAdaptable;
    +import org.apache.brooklyn.api.mgmt.TaskFactory;
    +import org.apache.brooklyn.core.location.Locations;
    +import org.apache.brooklyn.location.ssh.SshMachineLocation;
    +import org.apache.brooklyn.util.collections.MutableList;
    +import org.apache.brooklyn.util.core.ResourceUtils;
    +import org.apache.brooklyn.util.core.task.DynamicTasks;
    +import org.apache.brooklyn.util.core.task.ssh.SshTasks;
    +import org.apache.brooklyn.util.core.task.system.ProcessTaskFactory;
    +import org.apache.brooklyn.util.core.task.system.ProcessTaskWrapper;
    +import org.apache.brooklyn.util.exceptions.Exceptions;
    +import org.apache.brooklyn.util.exceptions.FatalRuntimeException;
    +import org.apache.brooklyn.util.guava.Maybe;
    +import org.apache.brooklyn.util.text.Strings;
    +import org.slf4j.Logger;
    +import org.slf4j.LoggerFactory;
    +
    +import java.net.MalformedURLException;
    +import java.net.URL;
    +import java.util.Collection;
    +import java.util.Collections;
    +import java.util.Iterator;
    +import java.util.Random;
    +
    +import static com.google.common.base.Preconditions.checkNotNull;
    +import static org.apache.brooklyn.util.text.Strings.isBlank;
    +
    +/**
    + * Driver for {@link SimpleCommand}.
    + */
    +public class SimpleCommandSshDriver implements SimpleCommandDriver {
    +
    +    private static final Logger LOG = LoggerFactory.getLogger(SimpleCommandSshDriver.class);
    +    public static final String DEFAULT_NAME = "download.sh";
    +
    +    protected final EntityLocal entity;
    +    protected final ResourceUtils resource;
    +    protected final Location location;
    +
    +    public SimpleCommandSshDriver(EntityLocal entity, SshMachineLocation location) {
    +        LOG.debug("Constructing SSH driver for simple command for {} at {}", entity,
location);
    +        this.entity = checkNotNull(entity, "entity");
    +        this.location = checkNotNull(location, "location");
    +        this.resource = ResourceUtils.create(entity);
    +    }
    +
    +    @Override
    +    public EntityLocal getEntity() {
    +        return entity;
    +    }
    +
    +    @Override
    +    public void start() {
    +        LOG.debug("Performing start in SSH driver for simple command");
    +        invoke();
    +    }
    +
    +    private void invoke() {
    +        SimpleCommand simpleCommand = (SimpleCommand) getEntity();
    +        simpleCommand.start(ImmutableList.of(location));
    --- End diff --
    
    Yes, this came from aiming for a simpler copy of the VanillaSoftwareProcess/SoftwareProcessDriver/SoftwareProcessDriverLifecycleEffectorTasks
structure, but it's probably one indirection too many. Thankfully it can go away if we simplify
things as discussed [above](https://github.com/apache/incubator-brooklyn/pull/1030#discussion_r44902393).


---
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