Skip to content
This repository was archived by the owner on Nov 12, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* 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.mementos;

import java.util.Collection;
import java.util.Map;

public interface BrooklynCatalogMementoManifest {
CatalogItemMemento getCatalogItemMemento(String id);
Collection<String> getCatalogItemIds();
Map<String, CatalogItemMemento> getCatalogItemMementos();
boolean isEmpty();
}
23 changes: 9 additions & 14 deletions api/src/main/java/brooklyn/mementos/BrooklynMementoManifest.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
package brooklyn.mementos;

import java.io.Serializable;
import java.util.Collection;
import java.util.Map;

import brooklyn.entity.trait.Identifiable;
Expand All @@ -29,30 +28,26 @@
*
* @author aled
*/
public interface BrooklynMementoManifest extends Serializable {
public interface EntityMementoManifest extends Identifiable{
public interface BrooklynMementoManifest extends BrooklynCatalogMementoManifest, Serializable {
public interface MementoManifest extends Identifiable {
@Override
public String getId();
public String getType();
public String getParent();
public String getCatalogItemId();
}

public Map<String, EntityMementoManifest> getEntityIdToManifest();
public Map<String, MementoManifest> getEntityIdToManifest();

public Map<String, String> getLocationIdToType();
public Map<String, MementoManifest> getLocationIdToManifest();

public Map<String, String> getPolicyIdToType();
public Map<String, MementoManifest> getPolicyIdToManifest();

public Map<String, String> getEnricherIdToType();
public Map<String, MementoManifest> getEnricherIdToManifest();

public Map<String, String> getFeedIdToType();
public Map<String, MementoManifest> getFeedIdToManifest();

public CatalogItemMemento getCatalogItemMemento(String id);

public Collection<String> getCatalogItemIds();

public Map<String, CatalogItemMemento> getCatalogItemMementos();

@Override
public boolean isEmpty();

}
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
* Controls the persisting and reading back of mementos. Used by {@link RebindManager}
* to support brooklyn restart.
*/
//TODO should split into persistence data load/save; serializer/deserializer; persister daemon
public interface BrooklynMementoPersister {

public static interface LookupContext {
Expand All @@ -73,6 +74,8 @@ public static interface LookupContext {
*/
BrooklynMementoRawData loadMementoRawData(RebindExceptionHandler exceptionHandler);

BrooklynCatalogMementoManifest loadCatalogMementos(BrooklynMementoRawData mementoData, RebindExceptionHandler exceptionHandler);

/** @deprecated since 0.7.0 use {@link #loadMementoManifest(BrooklynMementoRawData, RebindExceptionHandler)} */
BrooklynMementoManifest loadMementoManifest(RebindExceptionHandler exceptionHandler) throws IOException;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public CatalogItemBuilder<CatalogItemType> deprecated(boolean deprecated) {
return this;
}

public CatalogItemBuilder<CatalogItemType> libraries(Collection<CatalogBundle> libraries) {
public CatalogItemBuilder<CatalogItemType> libraries(Collection<? extends CatalogBundle> libraries) {
dto.setLibraries(libraries);
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public abstract class CatalogItemDtoAbstract<T, SpecT> extends AbstractBrooklynO
private @Deprecated @SetFromFlag String type;
private @SetFromFlag String planYaml;

private @SetFromFlag Collection<CatalogBundle> libraries;
private @SetFromFlag Collection<? extends CatalogBundle> libraries;
private @SetFromFlag Set<Object> tags = Sets.newLinkedHashSet();
private @SetFromFlag boolean deprecated;

Expand Down Expand Up @@ -337,7 +337,7 @@ protected void setPlanYaml(String planYaml) {
this.planYaml = planYaml;
}

protected void setLibraries(Collection<CatalogBundle> libraries) {
protected void setLibraries(Collection<? extends CatalogBundle> libraries) {
this.libraries = libraries;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ protected void doRun() throws Exception {
* so there is a short window for data loss between this write and the subsequent read.
*/
@Override
protected void loadManifestFiles() throws Exception {
protected void loadRawMementos() {
checkEnteringPhase(1);
Builder mementoRawBuilder = BrooklynMementoRawData.builder();

Expand Down Expand Up @@ -125,10 +125,20 @@ protected void loadManifestFiles() throws Exception {
}
// then rebuild
mementoRawData = mementoRawBuilder.build();
}

@Override
protected void instantiateCatalogMementos() {
checkEnteringPhase(2);
//NOP
}

@Override
protected void loadMementoManifest() throws Exception {
checkEnteringPhase(4);
preprocessManifestFiles();
}

@Override
protected void preprocessManifestFiles() throws Exception {
for (CompoundTransformer transformer: transformers) {
Expand All @@ -140,8 +150,8 @@ protected void preprocessManifestFiles() throws Exception {

@Override
protected void rebuildCatalog() {
checkEnteringPhase(2);
checkContinuingPhase(2);

// skip; old catalog items should be re-used
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/
package brooklyn.entity.rebind;

import java.io.IOException;
import java.util.Set;
import java.util.concurrent.Semaphore;
import java.util.concurrent.atomic.AtomicInteger;
Expand Down Expand Up @@ -70,11 +71,25 @@ protected void doRun() throws Exception {
}

@Override
protected void loadManifestFiles() throws Exception {
protected void loadRawMementos() {
checkEnteringPhase(1);
Preconditions.checkState(mementoRawData==null, "Memento raw data should not yet be set when calling this");
mementoRawData = persistenceStoreAccess.loadMementoRawData(exceptionHandler);

}

@Override
protected void instantiateCatalogMementos() {
checkEnteringPhase(2);
Preconditions.checkState(mementoRawData!=null, "Memento raw data should be set when calling this");
Preconditions.checkState(mementoCatalogManifest==null, "Catalog mementos should not be loaded when calling this");

mementoCatalogManifest = persistenceStoreAccess.loadCatalogMementos(mementoRawData, exceptionHandler);
}

@Override
protected void loadMementoManifest() throws Exception {
checkEnteringPhase(4);

preprocessManifestFiles();

if (!isEmpty) {
Expand Down
Loading