Github user aledsage commented on a diff in the pull request:

    https://github.com/apache/incubator-brooklyn/pull/642#discussion_r30493993
  
    --- Diff: 
sandbox/nosql/src/main/java/brooklyn/entity/nosql/hazelcast/HazelcastNodeSshDriver.java
 ---
    @@ -0,0 +1,112 @@
    +/*
    + * 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.nosql.hazelcast;
    +
    +import static java.lang.String.format;
    +import java.util.List;
    +import brooklyn.entity.basic.AbstractSoftwareProcessSshDriver;
    +import brooklyn.entity.basic.Entities;
    +import brooklyn.entity.basic.EntityLocal;
    +import brooklyn.location.basic.SshMachineLocation;
    +import brooklyn.util.collections.MutableMap;
    +import brooklyn.util.os.Os;
    +import brooklyn.util.ssh.BashCommands;
    +
    +import com.google.common.collect.ImmutableList;
    +
    +public class HazelcastNodeSshDriver extends 
AbstractSoftwareProcessSshDriver implements HazelcastNodeDriver {
    +
    +    public HazelcastNodeSshDriver(EntityLocal entity, SshMachineLocation 
machine) {
    +        super(entity, machine);
    +    }
    +
    +    @Override
    +    public void preInstall() {
    +        resolver = Entities.newDownloader(this);
    +    }
    +
    +    @Override
    +    public void install() {
    +        List<String> urls = resolver.getTargets();
    +        String saveAs = resolver.getFilename();
    +        
    +        List<String> commands = ImmutableList.<String>builder()
    +            .add(BashCommands.installJavaLatestOrWarn())
    +            .addAll(BashCommands.commandsToDownloadUrlsAs(urls, saveAs))
    +            .build();
    +        
    +        newScript(INSTALLING).body.append(commands).execute();
    +    }
    +
    +    @Override
    +    public void customize() {
    +
    +           ImmutableList.Builder<String> commands = new 
ImmutableList.Builder<String>()
    +                .add("mkdir -p lib conf log")
    +                .add(String.format("cp %s/%s %s/lib/", getInstallDir(), 
resolver.getFilename(), getRunDir()));
    +
    +        newScript(CUSTOMIZING)
    +                .body.append(commands.build())
    +                .failOnNonZeroResultCode()
    +                .execute();
    +        
    +        
copyTemplate(entity.getConfig(HazelcastNode.TEMPLATE_CONFIGURATION_URL), 
Os.mergePaths(getRunDir(), "conf", getConfigFile()));
    +        
    +    }
    +
    +    @Override
    +    public void launch() {
    +        
    +        entity.setAttribute(HazelcastNode.PID_FILE, 
Os.mergePathsUnix(getRunDir(), PID_FILENAME));
    +        
    +        StringBuilder commandBuilder = new StringBuilder()
    +            .append(format("nohup java -cp ./lib/hazelcast-%s.jar", 
getVersion()));
    --- End diff --
    
    I see you've followed the same pattern as elsewhere for setting the 
`resolver` field in the superclass. However, I think that might be a (subtly) 
bad pattern. If we stop and restart Brooklyn, then it restores the entities 
based on their config+attributes, and calling `rebind()`. I don't think 
anything will re-set the `resolver` field in the driver.
    
    I suggest you don't worry about that in your pull request. We should 
refactor + fix that across the board (probably in the super-class) in a 
separate pull request, rather than doing something specific for hazelcast.


---
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 [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to