mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
Some minor cleanups. Added a few missing operations to console.
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@3182 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -94,6 +94,7 @@ public class AVMInteractiveConsole
|
||||
while (!done)
|
||||
{
|
||||
String command[] = null;
|
||||
System.out.print("> ");
|
||||
try
|
||||
{
|
||||
String line = fIn.readLine();
|
||||
@@ -113,6 +114,7 @@ public class AVMInteractiveConsole
|
||||
{
|
||||
continue;
|
||||
}
|
||||
long start = System.currentTimeMillis();
|
||||
try
|
||||
{
|
||||
if (command[0].equals("ls"))
|
||||
@@ -131,6 +133,17 @@ public class AVMInteractiveConsole
|
||||
System.out.println(name + " " + listing.get(name));
|
||||
}
|
||||
}
|
||||
else if (command[0].equals("lsr"))
|
||||
{
|
||||
if (command.length != 3)
|
||||
{
|
||||
System.err.println("Syntax error.");
|
||||
continue;
|
||||
}
|
||||
AVMNodeDescriptor desc = fService.lookup(Integer.parseInt(command[2]),
|
||||
command[1]);
|
||||
recursiveList(desc, 0);
|
||||
}
|
||||
else if (command[0].equals("lsrep"))
|
||||
{
|
||||
List<String> repos = fService.getRepositoryNames();
|
||||
@@ -179,6 +192,15 @@ public class AVMInteractiveConsole
|
||||
}
|
||||
fService.createDirectory(command[1], command[2]);
|
||||
}
|
||||
else if (command[0].equals("mkbr"))
|
||||
{
|
||||
if (command.length != 5)
|
||||
{
|
||||
System.err.println("Syntax error.");
|
||||
continue;
|
||||
}
|
||||
fService.createBranch(Integer.parseInt(command[4]), command[1], command[2], command[3]);
|
||||
}
|
||||
else if (command[0].equals("mkldir"))
|
||||
{
|
||||
if (command.length != 4)
|
||||
@@ -188,6 +210,24 @@ public class AVMInteractiveConsole
|
||||
}
|
||||
fService.createLayeredDirectory(command[1], command[2], command[3]);
|
||||
}
|
||||
else if (command[0].equals("retarget"))
|
||||
{
|
||||
if (command.length != 3)
|
||||
{
|
||||
System.err.println("Syntax error.");
|
||||
continue;
|
||||
}
|
||||
fService.retargetLayeredDirectory(command[1], command[2]);
|
||||
}
|
||||
else if (command[0].equals("mkprimary"))
|
||||
{
|
||||
if (command.length != 2)
|
||||
{
|
||||
System.err.println("Syntax error.");
|
||||
continue;
|
||||
}
|
||||
fService.makePrimary(command[1]);
|
||||
}
|
||||
else if (command[0].equals("mklfile"))
|
||||
{
|
||||
if (command.length != 4)
|
||||
@@ -351,9 +391,28 @@ public class AVMInteractiveConsole
|
||||
{
|
||||
e.printStackTrace(System.err);
|
||||
}
|
||||
System.out.println("Time: " + (System.currentTimeMillis() - start));
|
||||
}
|
||||
fReaper.shutDown();
|
||||
}
|
||||
|
||||
private void recursiveList(AVMNodeDescriptor dir, int indent)
|
||||
{
|
||||
Map<String, AVMNodeDescriptor> listing = fService.getDirectoryListing(dir);
|
||||
for (String name : listing.keySet())
|
||||
{
|
||||
AVMNodeDescriptor child = listing.get(name);
|
||||
for (int i = 0; i < indent; i++)
|
||||
{
|
||||
System.out.print(' ');
|
||||
}
|
||||
System.out.println(name + " " + child);
|
||||
if (child.isDirectory())
|
||||
{
|
||||
recursiveList(child, indent + 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@@ -63,7 +63,7 @@ interface AVMNode
|
||||
* @param lPath The Lookup for this node.
|
||||
* @return A copy of ourself or null if no copy was necessary.
|
||||
*/
|
||||
public AVMNode possiblyCopy(Lookup lPath);
|
||||
public AVMNode copy(Lookup lPath);
|
||||
|
||||
/**
|
||||
* Set the repository for a node.
|
||||
|
@@ -35,9 +35,11 @@ public class AVMStressTest extends AVMServiceTestBase
|
||||
{
|
||||
try
|
||||
{
|
||||
int nCopies = 1;
|
||||
int nThreads = 16;
|
||||
BulkLoader loader = new BulkLoader(fService);
|
||||
long start = System.currentTimeMillis();
|
||||
for (int i = 0; i < 1; i++)
|
||||
for (int i = 0; i < nCopies; i++)
|
||||
{
|
||||
fService.createDirectory("main:/", "" + i);
|
||||
loader.recursiveLoad("source", "main:/" + i);
|
||||
@@ -46,17 +48,17 @@ public class AVMStressTest extends AVMServiceTestBase
|
||||
System.out.println("Load time: " + (System.currentTimeMillis() - start));
|
||||
List<AVMTester> testers = new ArrayList<AVMTester>();
|
||||
List<Thread> threads = new ArrayList<Thread>();
|
||||
for (int i = 0; i < 8; i++)
|
||||
for (int i = 0; i < nThreads; i++)
|
||||
{
|
||||
AVMTester tester
|
||||
= new AVMTester(400, // create file.
|
||||
10, // create dir,
|
||||
= new AVMTester(800, // create file.
|
||||
20, // create dir,
|
||||
0, // rename
|
||||
2, // create layered dir
|
||||
5, // create layered file
|
||||
10, // remove node
|
||||
20, // modify file.
|
||||
3600, // read file
|
||||
3200, // read file
|
||||
10, // snapshot
|
||||
10000, // # ops
|
||||
fService,
|
||||
@@ -74,12 +76,12 @@ public class AVMStressTest extends AVMServiceTestBase
|
||||
thread.start();
|
||||
}
|
||||
int exited = 0;
|
||||
while (exited != 8)
|
||||
while (exited != nThreads)
|
||||
{
|
||||
try
|
||||
{
|
||||
Thread.sleep(2000);
|
||||
for (int i = 0; i < 8; i++)
|
||||
for (int i = 0; i < nThreads; i++)
|
||||
{
|
||||
if (threads.get(i) == null)
|
||||
{
|
||||
|
@@ -226,12 +226,8 @@ class LayeredDirectoryNodeImpl extends DirectoryNodeImpl implements LayeredDirec
|
||||
* @param lPath
|
||||
* @return The copy or null.
|
||||
*/
|
||||
public AVMNodeImpl possiblyCopy(Lookup lPath)
|
||||
public AVMNode copy(Lookup lPath)
|
||||
{
|
||||
if (!lPath.needsCopying())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
// Capture the repository.
|
||||
Repository repo = lPath.getRepository();
|
||||
// Otherwise we do an actual copy.
|
||||
|
@@ -66,7 +66,7 @@ class LayeredFileNodeImpl extends FileNodeImpl implements LayeredFileNode
|
||||
* Copy on write logic.
|
||||
* @param lPath The path by which this was found.
|
||||
*/
|
||||
public AVMNode possiblyCopy(Lookup lPath)
|
||||
public AVMNode copy(Lookup lPath)
|
||||
{
|
||||
// LayeredFileNodes are always copied.
|
||||
Lookup lookup = SuperRepository.GetInstance().lookup(-1, fIndirection);
|
||||
|
@@ -153,20 +153,15 @@ class Lookup
|
||||
fComponents.add(comp);
|
||||
fPosition++;
|
||||
// If we are in a write context do copy on write.
|
||||
if (write)
|
||||
if (write && fNeedsCopying)
|
||||
{
|
||||
// Possibly copy.
|
||||
node = node.possiblyCopy(this);
|
||||
if (node == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
// Node was copied.
|
||||
node = node.copy(this);
|
||||
fComponents.get(fPosition).setNode(node);
|
||||
if (fPosition == 0)
|
||||
{
|
||||
// Inform the repository of a new root.
|
||||
fRepository.setNewRoot((DirectoryNode)node);
|
||||
SuperRepository.GetInstance().getSession().flush();
|
||||
return;
|
||||
}
|
||||
// Not the root. Check if we are the top layer and insert this into it's parent.
|
||||
@@ -175,6 +170,7 @@ class Lookup
|
||||
fTopLayer = (LayeredDirectoryNode)node;
|
||||
}
|
||||
((DirectoryNode)fComponents.get(fPosition - 1).getNode()).putChild(name, node);
|
||||
SuperRepository.GetInstance().getSession().flush();
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -202,13 +202,8 @@ class PlainDirectoryNodeImpl extends DirectoryNodeImpl implements PlainDirectory
|
||||
* @param lPath The lookup path.
|
||||
* @return
|
||||
*/
|
||||
public AVMNode possiblyCopy(Lookup lPath)
|
||||
public AVMNode copy(Lookup lPath)
|
||||
{
|
||||
if (!lPath.needsCopying())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
// Otherwise do an actual copy.
|
||||
DirectoryNode newMe = null;
|
||||
// In a layered context a copy on write creates a new
|
||||
// layered directory.
|
||||
|
@@ -84,12 +84,8 @@ class PlainFileNodeImpl extends FileNodeImpl implements PlainFileNode
|
||||
* Copy on write logic.
|
||||
* @param lPath The lookup path.
|
||||
*/
|
||||
public AVMNodeImpl possiblyCopy(Lookup lPath)
|
||||
public AVMNode copy(Lookup lPath)
|
||||
{
|
||||
if (!lPath.needsCopying())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
PlainFileNodeImpl newMe = new PlainFileNodeImpl(this, lPath.getRepository());
|
||||
newMe.setAncestor(this);
|
||||
return newMe;
|
||||
|
Reference in New Issue
Block a user