brooklyn-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aledsage <>
Subject [GitHub] brooklyn-server pull request: SoftLayer VLAN customizer
Date Thu, 24 Mar 2016 14:56:17 GMT
Github user aledsage commented on a diff in the pull request:
    --- Diff: locations/jclouds/src/main/java/org/apache/brooklyn/location/jclouds/softlayer/
    @@ -0,0 +1,398 @@
    + * 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
    + *
    + *
    + *
    + * Unless required by applicable law or agreed to in writing,
    + * software distributed under the License is distributed on an
    + * KIND, either express or implied.  See the License for the
    + * specific language governing permissions and limitations
    + * under the License.
    + */
    +package org.apache.brooklyn.location.jclouds.softlayer;
    +import java.util.Map;
    +import java.util.concurrent.CountDownLatch;
    +import java.util.concurrent.TimeUnit;
    +import javax.annotation.concurrent.ThreadSafe;
    +import org.slf4j.Logger;
    +import org.slf4j.LoggerFactory;
    +import org.jclouds.compute.ComputeService;
    +import org.jclouds.compute.options.TemplateOptions;
    +import org.jclouds.softlayer.SoftLayerApi;
    +import org.jclouds.softlayer.compute.options.SoftLayerTemplateOptions;
    +import org.jclouds.softlayer.domain.VirtualGuest;
    +import org.jclouds.softlayer.features.VirtualGuestApi;
    +import org.jclouds.softlayer.reference.SoftLayerConstants;
    +import org.apache.brooklyn.api.entity.Entity;
    +import org.apache.brooklyn.api.sensor.AttributeSensor;
    +import org.apache.brooklyn.config.ConfigKey;
    +import org.apache.brooklyn.core.config.ConfigKeys;
    +import org.apache.brooklyn.core.location.LocationConfigKeys;
    +import org.apache.brooklyn.core.sensor.Sensors;
    +import org.apache.brooklyn.location.jclouds.BasicJcloudsLocationCustomizer;
    +import org.apache.brooklyn.location.jclouds.JcloudsLocation;
    +import org.apache.brooklyn.location.jclouds.JcloudsLocationCustomizer;
    +import org.apache.brooklyn.location.jclouds.JcloudsMachineLocation;
    +import org.apache.brooklyn.location.jclouds.JcloudsSshMachineLocation;
    +import org.apache.brooklyn.util.collections.MutableMap;
    +import org.apache.brooklyn.util.core.flags.SetFromFlag;
    +import org.apache.brooklyn.util.core.task.Tasks;
    +import org.apache.brooklyn.util.text.Strings;
    +import org.apache.brooklyn.util.time.Duration;
    + * Customizes {@link JcloudsSshMachineLocation machines} in SoftLayer to use
    + * the same VLANs across an application, or other named scope
    + * <p>
    + * Define the scope by setting the {@link #SCOPE_UID scopeUid} ({@code softlayer.vlan.scopeUid})
    + * option. If unset or blank, will default to the {@link Entity#getApplicationId() application
    + * of the entity being deployed on the machine. Set {@link #SCOPE_TIMEOUT scopeTimeout}
    + * ({@code softlayer.vlan.timeout}) to change the length of time the customizer
    + * will wait for VLAN information; normally ten minutes.
    + * <p>
    + * The VLAN IDs and latches are stored as {@link ConfigKey configuration} on
    + * the {@link JcloudsLocation location} provisioning the VMs, in a map keyed
    + * on the scope.
    + */
    +public class SoftLayerSameVlanLocationCustomizer extends BasicJcloudsLocationCustomizer
    +    private static final Logger LOG = LoggerFactory.getLogger(SoftLayerSameVlanLocationCustomizer.class);
    +    @SetFromFlag("scopeUid")
    +    public static final ConfigKey<String> SCOPE_UID = ConfigKeys.newStringConfigKey(
    +            "softlayer.vlan.scopeUid",
    +            "The unique identifier for a Softlayer location scope that will have VMs
created in the same VLAN");
    +    @SetFromFlag("scopeTimeout")
    +    public static final ConfigKey<Duration> SCOPE_TIMEOUT = ConfigKeys.newDurationConfigKey(
    +            "softlayer.vlan.timeout",
    +            "The length of time to wait for a Softlayer VLAN ID",
    +            Duration.minutes(15));
    +    public static final ConfigKey<Map<String, CountDownLatch>> COUNTDOWN_LATCH_MAP
= ConfigKeys.newConfigKey(
    +            new TypeToken<Map<String, CountDownLatch>>() { },
    +            "",
    +            "A mapping from scope identifiers to CountDownLatches; used to synchronize
    +            MutableMap.<String, CountDownLatch>of());
    --- End diff --
    The default value for a config key should *never* be mutable! If it is, then someone can
get the default value and modify the object. Someone else who then uses the same config key
on a different entity/customizer will get the modified object as their default.

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

View raw message