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: Active partial rebind allowing ca...
Date Mon, 09 Feb 2015 11:23:57 GMT
Github user aledsage commented on a diff in the pull request:

    https://github.com/apache/incubator-brooklyn/pull/506#discussion_r24321929
  
    --- Diff: core/src/main/java/brooklyn/entity/rebind/ActivePartialRebindIteration.java
---
    @@ -0,0 +1,158 @@
    +/*
    + * 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.rebind;
    +
    +import java.util.Collection;
    +import java.util.Iterator;
    +import java.util.List;
    +import java.util.Set;
    +import java.util.concurrent.Semaphore;
    +import java.util.concurrent.atomic.AtomicInteger;
    +
    +import org.slf4j.Logger;
    +import org.slf4j.LoggerFactory;
    +
    +import brooklyn.basic.BrooklynObject;
    +import brooklyn.basic.BrooklynObjectInternal;
    +import brooklyn.entity.Entity;
    +import brooklyn.entity.basic.EntityInternal;
    +import brooklyn.entity.rebind.persister.BrooklynMementoPersisterToObjectStore;
    +import brooklyn.entity.rebind.persister.PersistenceActivityMetrics;
    +import brooklyn.entity.rebind.transformer.CompoundTransformer;
    +import brooklyn.management.ha.ManagementNodeState;
    +import brooklyn.mementos.BrooklynMementoPersister;
    +import brooklyn.mementos.BrooklynMementoRawData;
    +import brooklyn.mementos.BrooklynMementoRawData.Builder;
    +import brooklyn.mementos.Memento;
    +import brooklyn.util.collections.MutableList;
    +import brooklyn.util.collections.MutableSet;
    +
    +import com.google.common.base.Preconditions;
    +
    +/**
    + * Pauses a set of existing entities, writes their state, applies a transformation, then
reads them back.
    + */
    +public class ActivePartialRebindIteration extends RebindIteration {
    +
    +    private static final Logger LOG = LoggerFactory.getLogger(ActivePartialRebindIteration.class);
    +    
    +    protected Iterator<BrooklynObject> objectsToRebindInitial;
    +    protected Collection<BrooklynObject> objectsToRebindFinal;
    +    protected List<CompoundTransformer> transformers = MutableList.of();
    +    
    +    public ActivePartialRebindIteration(RebindManagerImpl rebindManager, 
    +            ManagementNodeState mode,
    +            ClassLoader classLoader, RebindExceptionHandler exceptionHandler,
    +            Semaphore rebindActive, AtomicInteger readOnlyRebindCount, PersistenceActivityMetrics
rebindMetrics, BrooklynMementoPersister persistenceStoreAccess
    +            ) {
    +        super(rebindManager, mode, classLoader, exceptionHandler, rebindActive, readOnlyRebindCount,
rebindMetrics, persistenceStoreAccess);
    +    }
    +
    +    @Override
    +    protected boolean isRebindingActiveAgain() {
    +        return true;
    +    }
    +    
    +    public void setObjectIterator(Iterator<BrooklynObject> objectsToRebind) {
    +        this.objectsToRebindInitial = objectsToRebind;
    +    }
    +    
    +    public void applyTransformer(CompoundTransformer transformer) {
    +        if (transformer!=null)
    --- End diff --
    
    I still have a general preference for us not to ignore nulls like this. It's a serious
risk of ignoring problems with surprising behaviour, versus the convenience of the caller
not having to check for null. The time I lean towards accepting nulls is if it's in a fluent
API.


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