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); fService.createAVMStore("d" + i);
loader.recursiveLoad("source", "d" + i + ":/"); loader.recursiveLoad("source", "d" + i + ":/");
fService.createSnapshot("d" + i); fService.createSnapshot("d" + i, null, null);
} }
long startTime = System.currentTimeMillis(); long startTime = System.currentTimeMillis();
List<AVMCrawler> crawlers = new ArrayList<AVMCrawler>(); List<AVMCrawler> crawlers = new ArrayList<AVMCrawler>();

View File

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

View File

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

View File

@@ -586,6 +586,7 @@ public class AVMRemoteImpl implements AVMRemote, Runnable
return fAVMService.createSnapshot(stores); return fAVMService.createSnapshot(stores);
} }
// TODO update this if it's ever needed.
/** /**
* Snapshot an AVMStore. * Snapshot an AVMStore.
* @param store The name of the AVMStore to snapshot. * @param store The name of the AVMStore to snapshot.
@@ -593,7 +594,7 @@ public class AVMRemoteImpl implements AVMRemote, Runnable
*/ */
public int createSnapshot(String store) 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) if (version < 0)
{ {
version = srcRepo.createSnapshot(); version = srcRepo.createSnapshot("Branch Snapshot", null);
} }
sPath = srcRepo.lookup(version, pathParts[1], false, false); sPath = srcRepo.lookup(version, pathParts[1], false, false);
if (sPath == null) if (sPath == null)
@@ -592,7 +592,7 @@ public class AVMRepository
{ {
throw new AVMNotFoundException("Store not found."); throw new AVMNotFoundException("Store not found.");
} }
result.add(store.createSnapshot()); result.add(store.createSnapshot(null, null));
} }
return result; return result;
} }
@@ -600,16 +600,18 @@ public class AVMRepository
/** /**
* Create a snapshot of a single AVMStore. * Create a snapshot of a single AVMStore.
* @param store The name of the repository. * @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. * @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); AVMStore store = getAVMStoreByName(storeName);
if (store == null) if (store == null)
{ {
throw new AVMNotFoundException("Store not found."); 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. * Snapshot an AVMRepository.
* @param store The name of the AVMStore. * @param store The name of the AVMStore.
* @param tag The short description.
* @param description The thick description.
* @return The id of the new version. * @return The id of the new version.
*/ */
public int createSnapshot(String store) public int createSnapshot(String store, String tag, String description)
{ {
if (store == null) if (store == null)
{ {
throw new AVMBadArgumentException("Store is 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); System.out.println(ndir + "/file" + i);
out.close(); out.close();
} }
fService.createSnapshot("main"); fService.createSnapshot("main", null, null);
} }
// System.out.println(recursiveList("main", -1)); // System.out.println(recursiveList("main", -1));
} }
@@ -78,7 +78,7 @@ public class AVMServicePerfTest extends AVMServiceTestBase
System.out.println(ndir + "/file" + i); System.out.println(ndir + "/file" + i);
out.close(); out.close();
} }
fService.createSnapshot("main"); fService.createSnapshot("main", null, null);
} }
// System.out.println(recursiveList("main", -1)); // System.out.println(recursiveList("main", -1));
} }
@@ -110,7 +110,7 @@ public class AVMServicePerfTest extends AVMServiceTestBase
System.out.println(ndir + "/file" + i); System.out.println(ndir + "/file" + i);
out.close(); out.close();
} }
fService.createSnapshot("main"); fService.createSnapshot("main", null, null);
} }
// System.out.println(recursiveList("main", -1)); // System.out.println(recursiveList("main", -1));
} }
@@ -142,7 +142,7 @@ public class AVMServicePerfTest extends AVMServiceTestBase
out.close(); out.close();
System.out.println(ndir + "/file" + i); System.out.println(ndir + "/file" + i);
} }
fService.createSnapshot("main"); fService.createSnapshot("main", null, null);
} }
// System.out.println(recursiveList("main", -1)); // 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 * Snapshots this store. This sets all nodes in the
* the store to the should be copied state, and creates * the store to the should be copied state, and creates
* a new version root. * a new version root.
* @param tag The short description.
* @param description The long description.
* @return The version id of the newly created snapshot. * @return The version id of the newly created snapshot.
*/ */
public int createSnapshot(); public int createSnapshot(String tag, String Description);
/** /**
* Create a new directory. * Create a new directory.

View File

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

View File

@@ -44,7 +44,7 @@ public class AVMStressTest extends AVMServiceTestBase
{ {
fService.createDirectory("main:/", "" + i); fService.createDirectory("main:/", "" + i);
loader.recursiveLoad("source", "main:/" + i); loader.recursiveLoad("source", "main:/" + i);
fService.createSnapshot("main"); fService.createSnapshot("main", null, null);
} }
System.out.println("Load time: " + (System.currentTimeMillis() - start)); System.out.println("Load time: " + (System.currentTimeMillis() - start));
List<AVMTester> testers = new ArrayList<AVMTester>(); 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 * @param overrideConflicts If this is true the update will override conflicting
* AVMDifferences and replace the destination with the conflicting source. * AVMDifferences and replace the destination with the conflicting source.
* @param overrideOlder If this is true the update will override AVMDifferences * @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. * in which the source is older than the destination and overwrite the destination.
*/ */
public void update(List<AVMDifference> diffList, boolean ignoreConflicts, boolean ignoreOlder, 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>(); Map<String, Integer> storeVersions = new HashMap<String, Integer>();
Set<String> destStores = new HashSet<String>(); Set<String> destStores = new HashSet<String>();
@@ -310,7 +312,7 @@ public class AVMSyncServiceImpl implements AVMSyncService
} }
else else
{ {
version = fAVMService.createSnapshot(storeName); version = fAVMService.createSnapshot(storeName, "Snapshotted for submit.", null);
} }
} }
AVMNodeDescriptor srcDesc = fAVMService.lookup(version, AVMNodeDescriptor srcDesc = fAVMService.lookup(version,
@@ -401,7 +403,7 @@ public class AVMSyncServiceImpl implements AVMSyncService
} }
for (String storeName : destStores) 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"); System.out.println("snapshot");
try try
{ {
fService.createSnapshot("main"); fService.createSnapshot("main", null, null);
} }
catch (Exception e) catch (Exception e)
{ {

View File

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

View File

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

View File

@@ -83,4 +83,16 @@ public interface VersionRoot
* @return The version id. * @return The version id.
*/ */
public int getVersionID(); 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; private DirectoryNode fRoot;
/**
* The short description.
*/
private String fTag;
/**
* The thick description.
*/
private String fDescription;
/** /**
* A default constructor. * A default constructor.
*/ */
@@ -77,13 +87,17 @@ class VersionRootImpl implements VersionRoot, Serializable
DirectoryNode root, DirectoryNode root,
int versionID, int versionID,
long createDate, long createDate,
String creator) String creator,
String tag,
String description)
{ {
fAVMStore = store; fAVMStore = store;
fRoot = root; fRoot = root;
fVersionID = versionID; fVersionID = versionID;
fCreateDate = createDate; fCreateDate = createDate;
fCreator = creator; fCreator = creator;
fTag = tag;
fDescription = description;
} }
public long getCreateDate() public long getCreateDate()
@@ -184,5 +198,41 @@ class VersionRootImpl implements VersionRoot, Serializable
{ {
return fAVMStore.hashCode() + fVersionID; 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. // Find the differences.
List<AVMDifference> diffs = List<AVMDifference> diffs =
fAVMSyncService.compare(version, path, -1, targetPath); fAVMSyncService.compare(version, path, -1, targetPath);
// TODO fix update comments at some point.
// Do the promote. // 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. // Flatten the source on top of the destination.
fAVMSyncService.flatten(storePath[0] + ":/appBase", fAVMSyncService.flatten(storePath[0] + ":/appBase",
targetStoreName + ":/appBase"); targetStoreName + ":/appBase");

View File

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

View File

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

View File

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

View File

@@ -86,7 +86,8 @@ public class AVMSubmitPackageHandler extends JBPMSpringActionHandler implements
diffs.add(diff); diffs.add(diff);
storesHit.put(storePath[0], stagingName); 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()) for (Map.Entry<String, String> entry : storesHit.entrySet())
{ {
fAVMSyncService.flatten(entry.getKey() + ":/appBase", fAVMSyncService.flatten(entry.getKey() + ":/appBase",

View File

@@ -317,9 +317,11 @@ public interface AVMService
/** /**
* Snapshot the given AVMStore. * Snapshot the given AVMStore.
* @param store The name of the AVMStore to snapshot. * @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. * @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 * 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. * AVMDifferences and replace the destination with the conflicting source.
* @param overrideOlder If this is true the update will override AVMDifferences * @param overrideOlder If this is true the update will override AVMDifferences
* in which the source is older than the destination and overwrite the destination. * 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, 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 * Flattens a layer so that all all nodes under and including