Added two new fields to VersionRoot (the version record), a short description,

and a long description.  Adjusted signature of createSnapshot(), and update()
to match, and thus actions and tests that needed to be fixed.


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@4290 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Britt Park
2006-11-05 23:41:55 +00:00
parent 2355b9e00f
commit f501073de5
24 changed files with 314 additions and 229 deletions

View File

@@ -45,7 +45,7 @@ public class AVMCrawlTest extends AVMServiceTestBase
{
fService.createAVMStore("d" + i);
loader.recursiveLoad("source", "d" + i + ":/");
fService.createSnapshot("d" + i);
fService.createSnapshot("d" + i, null, null);
}
long startTime = System.currentTimeMillis();
List<AVMCrawler> crawlers = new ArrayList<AVMCrawler>();

View File

@@ -219,7 +219,7 @@ class AVMCrawler implements Runnable
}
if (fRandom.nextInt(16) == 0)
{
fService.createSnapshot(repDesc.getName());
fService.createSnapshot(repDesc.getName(), null, null);
fOpCount++;
}
}

View File

@@ -301,7 +301,7 @@ public class AVMInterpreter
{
return "Syntax Error.";
}
fService.createSnapshot(command[1]);
fService.createSnapshot(command[1], null, null);
}
else if (command[0].equals("cat"))
{
@@ -482,7 +482,7 @@ public class AVMInterpreter
-1, command[3], AVMDifference.NEWER);
List<AVMDifference> diffs = new ArrayList<AVMDifference>();
diffs.add(diff);
fSyncService.update(diffs, false, false, false, false);
fSyncService.update(diffs, false, false, false, false, null, null);
}
else if (command[0].equals("resetLayer"))
{

View File

@@ -586,6 +586,7 @@ public class AVMRemoteImpl implements AVMRemote, Runnable
return fAVMService.createSnapshot(stores);
}
// TODO update this if it's ever needed.
/**
* Snapshot an AVMStore.
* @param store The name of the AVMStore to snapshot.
@@ -593,7 +594,7 @@ public class AVMRemoteImpl implements AVMRemote, Runnable
*/
public int createSnapshot(String store)
{
return fAVMService.createSnapshot(store);
return fAVMService.createSnapshot(store, null, null);
}
/**

View File

@@ -312,7 +312,7 @@ public class AVMRepository
}
if (version < 0)
{
version = srcRepo.createSnapshot();
version = srcRepo.createSnapshot("Branch Snapshot", null);
}
sPath = srcRepo.lookup(version, pathParts[1], false, false);
if (sPath == null)
@@ -592,7 +592,7 @@ public class AVMRepository
{
throw new AVMNotFoundException("Store not found.");
}
result.add(store.createSnapshot());
result.add(store.createSnapshot(null, null));
}
return result;
}
@@ -600,16 +600,18 @@ public class AVMRepository
/**
* Create a snapshot of a single AVMStore.
* @param store The name of the repository.
* @param tag The short description.
* @param description The thick description.
* @return The version id of the newly snapshotted repository.
*/
public int createSnapshot(String storeName)
public int createSnapshot(String storeName, String tag, String description)
{
AVMStore store = getAVMStoreByName(storeName);
if (store == null)
{
throw new AVMNotFoundException("Store not found.");
}
return store.createSnapshot();
return store.createSnapshot(tag, description);
}
/**

View File

@@ -470,15 +470,17 @@ public class AVMServiceImpl implements AVMService
/**
* Snapshot an AVMRepository.
* @param store The name of the AVMStore.
* @param tag The short description.
* @param description The thick description.
* @return The id of the new version.
*/
public int createSnapshot(String store)
public int createSnapshot(String store, String tag, String description)
{
if (store == null)
{
throw new AVMBadArgumentException("Store is null.");
}
return fAVMRepository.createSnapshot(store);
return fAVMRepository.createSnapshot(store, tag, description);
}
/**

View File

@@ -46,7 +46,7 @@ public class AVMServicePerfTest extends AVMServiceTestBase
System.out.println(ndir + "/file" + i);
out.close();
}
fService.createSnapshot("main");
fService.createSnapshot("main", null, null);
}
// System.out.println(recursiveList("main", -1));
}
@@ -78,7 +78,7 @@ public class AVMServicePerfTest extends AVMServiceTestBase
System.out.println(ndir + "/file" + i);
out.close();
}
fService.createSnapshot("main");
fService.createSnapshot("main", null, null);
}
// System.out.println(recursiveList("main", -1));
}
@@ -110,7 +110,7 @@ public class AVMServicePerfTest extends AVMServiceTestBase
System.out.println(ndir + "/file" + i);
out.close();
}
fService.createSnapshot("main");
fService.createSnapshot("main", null, null);
}
// System.out.println(recursiveList("main", -1));
}
@@ -142,7 +142,7 @@ public class AVMServicePerfTest extends AVMServiceTestBase
out.close();
System.out.println(ndir + "/file" + i);
}
fService.createSnapshot("main");
fService.createSnapshot("main", null, null);
}
// System.out.println(recursiveList("main", -1));
}

File diff suppressed because it is too large Load Diff

View File

@@ -55,9 +55,11 @@ public interface AVMStore
* Snapshots this store. This sets all nodes in the
* the store to the should be copied state, and creates
* a new version root.
* @param tag The short description.
* @param description The long description.
* @return The version id of the newly created snapshot.
*/
public int createSnapshot();
public int createSnapshot(String tag, String Description);
/**
* Create a new directory.

View File

@@ -122,7 +122,9 @@ public class AVMStoreImpl implements AVMStore, Serializable
fRoot,
fNextVersionID,
time,
creator);
creator,
"Initial Empty Version.",
"Initial Empty Version.");
fNextVersionID++;
AVMDAOs.Instance().fVersionRootDAO.save(versionRoot);
}
@@ -142,7 +144,7 @@ public class AVMStoreImpl implements AVMStore, Serializable
* @return The version id of the new snapshot.
*/
@SuppressWarnings("unchecked")
public int createSnapshot()
public int createSnapshot(String tag, String description)
{
// If the root isn't new, we can't take a snapshot since nothing has changed.
if (!fRoot.getIsNew())
@@ -166,7 +168,9 @@ public class AVMStoreImpl implements AVMStore, Serializable
fRoot,
fNextVersionID,
System.currentTimeMillis(),
user);
user,
tag,
description);
AVMDAOs.Instance().fVersionRootDAO.save(versionRoot);
// Increment the version id.
fNextVersionID++;

View File

@@ -44,7 +44,7 @@ public class AVMStressTest extends AVMServiceTestBase
{
fService.createDirectory("main:/", "" + i);
loader.recursiveLoad("source", "main:/" + i);
fService.createSnapshot("main");
fService.createSnapshot("main", null, null);
}
System.out.println("Load time: " + (System.currentTimeMillis() - start));
List<AVMTester> testers = new ArrayList<AVMTester>();

View File

@@ -280,10 +280,12 @@ public class AVMSyncServiceImpl implements AVMSyncService
* @param overrideConflicts If this is true the update will override conflicting
* AVMDifferences and replace the destination with the conflicting source.
* @param overrideOlder If this is true the update will override AVMDifferences
* @param tag Short update blurb.
* @param description Full update blurb.
* in which the source is older than the destination and overwrite the destination.
*/
public void update(List<AVMDifference> diffList, boolean ignoreConflicts, boolean ignoreOlder,
boolean overrideConflicts, boolean overrideOlder)
boolean overrideConflicts, boolean overrideOlder, String tag, String description)
{
Map<String, Integer> storeVersions = new HashMap<String, Integer>();
Set<String> destStores = new HashSet<String>();
@@ -310,7 +312,7 @@ public class AVMSyncServiceImpl implements AVMSyncService
}
else
{
version = fAVMService.createSnapshot(storeName);
version = fAVMService.createSnapshot(storeName, "Snapshotted for submit.", null);
}
}
AVMNodeDescriptor srcDesc = fAVMService.lookup(version,
@@ -401,7 +403,7 @@ public class AVMSyncServiceImpl implements AVMSyncService
}
for (String storeName : destStores)
{
fAVMService.createSnapshot(storeName);
fAVMService.createSnapshot(storeName, tag, description);
}
}

View File

@@ -478,7 +478,7 @@ class AVMTester implements Runnable
System.out.println("snapshot");
try
{
fService.createSnapshot("main");
fService.createSnapshot("main", null, null);
}
catch (Exception e)
{

View File

@@ -38,7 +38,7 @@ public class PurgeTest extends AVMServiceTestBase
long start = System.currentTimeMillis();
loader.recursiveLoad("source/web", "main:/");
System.err.println("Load time: " + (System.currentTimeMillis() - start) + "ms");
fService.createSnapshot("main");
fService.createSnapshot("main", null, null);
System.err.println("Load time + snapshot: " + (System.currentTimeMillis() - start) + "ms");
fService.purgeVersion(2, "main");
fReaper.activate();
@@ -74,10 +74,10 @@ public class PurgeTest extends AVMServiceTestBase
long start = System.currentTimeMillis();
loader.recursiveLoad("source", "main:/");
System.err.println("Load time: " + (System.currentTimeMillis() - start) + "ms");
fService.createSnapshot("main");
fService.createSnapshot("main", null, null);
System.err.println("Load time + snapshot: " + (System.currentTimeMillis() - start) + "ms");
fService.removeNode("main:/source/java/org/alfresco", "repo");
fService.createSnapshot("main");
fService.createSnapshot("main", null, null);
fService.purgeVersion(2, "main");
fReaper.activate();
while (fReaper.isActive())
@@ -112,12 +112,12 @@ public class PurgeTest extends AVMServiceTestBase
long start = System.currentTimeMillis();
loader.recursiveLoad("source", "main:/");
System.err.println("Load time: " + (System.currentTimeMillis() - start) + "ms");
fService.createSnapshot("main");
fService.createSnapshot("main", null, null);
System.err.println("Load time + snapshot: " + (System.currentTimeMillis() - start) + "ms");
fService.createLayeredDirectory("main:/source", "main:/", "layer");
fService.removeNode("main:/layer/java/org/alfresco", "repo");
fService.createFile("main:/layer/java/org/alfresco", "goofy").close();
fService.createSnapshot("main");
fService.createSnapshot("main", null, null);
fService.purgeAVMStore("main");
fReaper.activate();
while (fReaper.isActive())

View File

@@ -39,7 +39,7 @@ public class SimultaneousLoadTest extends AVMServiceTestBase
{
fService.createDirectory("main:/", "d" + i);
}
fService.createSnapshot("main");
fService.createSnapshot("main", null, null);
Thread [] threads = new Thread[n];
for (int i = 0; i < n; i++)
{

View File

@@ -83,4 +83,16 @@ public interface VersionRoot
* @return The version id.
*/
public int getVersionID();
/**
* Get the tag (short description).
* @return The tag.
*/
public String getTag();
/**
* Get the thick description.
* @return The thick description.
*/
public String getDescription();
}

View File

@@ -58,6 +58,16 @@ class VersionRootImpl implements VersionRoot, Serializable
*/
private DirectoryNode fRoot;
/**
* The short description.
*/
private String fTag;
/**
* The thick description.
*/
private String fDescription;
/**
* A default constructor.
*/
@@ -77,13 +87,17 @@ class VersionRootImpl implements VersionRoot, Serializable
DirectoryNode root,
int versionID,
long createDate,
String creator)
String creator,
String tag,
String description)
{
fAVMStore = store;
fRoot = root;
fVersionID = versionID;
fCreateDate = createDate;
fCreator = creator;
fTag = tag;
fDescription = description;
}
public long getCreateDate()
@@ -184,5 +198,41 @@ class VersionRootImpl implements VersionRoot, Serializable
{
return fAVMStore.hashCode() + fVersionID;
}
/**
* Get the tag (short description).
* @return The tag.
*/
public String getTag()
{
return fTag;
}
/**
* Set the tag (short description).
* @param tag The short description.
*/
public void setTag(String tag)
{
fTag = tag;
}
/**
* Get the thick description.
* @return The thick description.
*/
public String getDescription()
{
return fDescription;
}
/**
* Set the thick description.
* @param description The thick discription.
*/
public void setDescription(String description)
{
fDescription = description;
}
}

View File

@@ -90,8 +90,9 @@ public class SimpleAVMPromoteAction extends ActionExecuterAbstractBase
// Find the differences.
List<AVMDifference> diffs =
fAVMSyncService.compare(version, path, -1, targetPath);
// TODO fix update comments at some point.
// Do the promote.
fAVMSyncService.update(diffs, true, true, false, false);
fAVMSyncService.update(diffs, true, true, false, false, null, null);
// Flatten the source on top of the destination.
fAVMSyncService.flatten(storePath[0] + ":/appBase",
targetStoreName + ":/appBase");

View File

@@ -115,8 +115,9 @@ public class SimpleAVMSubmitAction extends ActionExecuterAbstractBase
// Get the difference between source and destination.
List<AVMDifference> diffs =
fAVMSyncService.compare(version, path, -1, avmDest);
// TODO fix update comments at some point.
// Do the update.
fAVMSyncService.update(diffs, false, false, true, true);
fAVMSyncService.update(diffs, false, false, true, true, null, null);
// Cleanup by flattening the source relative to the destination.
AVMDAOs.Instance().fAVMNodeDAO.flush();
fAVMSyncService.flatten(storePath[0] + ":/appBase", websiteName + "-staging:/appBase");

View File

@@ -132,6 +132,8 @@
<many-to-one name="root" class="DirectoryNodeImpl"
column="root_id" not-null="true">
</many-to-one>
<property name="tag" type="string" length="255" column="tag"/>
<property name="description" type="string" length="8192" column="description"/>
</class>
<class name="ChildEntryImpl" proxy="ChildEntry" table="avm_child_entries" optimistic-lock="version">
<cache usage="read-write"/>

View File

@@ -79,8 +79,9 @@ public class AVMSubmitHandler extends JBPMSpringActionHandler
String avmDest = webSiteName + "-staging:" + storePath[1];
List<AVMDifference> diffs =
fAVMSyncService.compare(-1, avmSource, -1, avmDest);
// TODO fix update comments if needed.
// Ignore conflicts and older nodes for now.
fAVMSyncService.update(diffs, true, true, false, false);
fAVMSyncService.update(diffs, true, true, false, false, null, null);
// Now flatten out the source.
fAVMSyncService.flatten(avmSource, avmDest);
}

View File

@@ -86,7 +86,8 @@ public class AVMSubmitPackageHandler extends JBPMSpringActionHandler implements
diffs.add(diff);
storesHit.put(storePath[0], stagingName);
}
fAVMSyncService.update(diffs, true, true, false, false);
// TODO fix update comments if needed.
fAVMSyncService.update(diffs, true, true, false, false, null, null);
for (Map.Entry<String, String> entry : storesHit.entrySet())
{
fAVMSyncService.flatten(entry.getKey() + ":/appBase",

View File

@@ -317,9 +317,11 @@ public interface AVMService
/**
* Snapshot the given AVMStore.
* @param store The name of the AVMStore to snapshot.
* @param tag The short description.
* @param description The thick description.
* @throws AVMNotFoundException If <code>store</code> does not exist.
*/
public int createSnapshot(String store);
public int createSnapshot(String store, String tag, String description);
/**
* Get the set of versions in an AVMStore

View File

@@ -53,9 +53,11 @@ public interface AVMSyncService
* AVMDifferences and replace the destination with the conflicting source.
* @param overrideOlder If this is true the update will override AVMDifferences
* in which the source is older than the destination and overwrite the destination.
* @param tag Short comment.
* @param description Full update blurb.
*/
public void update(List<AVMDifference> diffList, boolean ignoreConflicts, boolean ignoreOlder,
boolean overrideConflicts, boolean overrideOlder);
boolean overrideConflicts, boolean overrideOlder, String tag, String description);
/**
* Flattens a layer so that all all nodes under and including