summaryrefslogtreecommitdiff
path: root/java/test
diff options
context:
space:
mode:
authorDwayne Boone <dwayne@zeroc.com>2009-05-15 13:46:50 -0230
committerDwayne Boone <dwayne@zeroc.com>2009-05-15 13:46:50 -0230
commit0f8bb307adf2f03ef029b706d1e3dac9a2f56974 (patch)
tree21e4ce78d64556311d3aa9cdf559ac78eb05e629 /java/test
parentRemoved nonmutating keyword (diff)
downloadice-0f8bb307adf2f03ef029b706d1e3dac9a2f56974.tar.bz2
ice-0f8bb307adf2f03ef029b706d1e3dac9a2f56974.tar.xz
ice-0f8bb307adf2f03ef029b706d1e3dac9a2f56974.zip
Removed Freeze.UseNonmutating
Diffstat (limited to 'java/test')
-rw-r--r--java/test/Freeze/build.xml2
-rw-r--r--java/test/Freeze/oldevictor/.gitignore1
-rw-r--r--java/test/Freeze/oldevictor/Client.java916
-rw-r--r--java/test/Freeze/oldevictor/FacetI.java43
-rw-r--r--java/test/Freeze/oldevictor/RemoteEvictorFactoryI.java36
-rw-r--r--java/test/Freeze/oldevictor/RemoteEvictorI.java141
-rw-r--r--java/test/Freeze/oldevictor/ServantI.java201
-rw-r--r--java/test/Freeze/oldevictor/Server.java88
-rw-r--r--java/test/Freeze/oldevictor/Test.ice83
-rw-r--r--java/test/Freeze/oldevictor/build.xml32
-rw-r--r--java/test/Freeze/oldevictor/config10
-rw-r--r--java/test/Freeze/oldevictor/db/.gitignore1
-rwxr-xr-xjava/test/Freeze/oldevictor/run.py30
13 files changed, 0 insertions, 1584 deletions
diff --git a/java/test/Freeze/build.xml b/java/test/Freeze/build.xml
index 465c645d89b..d0f23fc6c3a 100644
--- a/java/test/Freeze/build.xml
+++ b/java/test/Freeze/build.xml
@@ -15,14 +15,12 @@
<ant dir="dbmap"/>
<ant dir="complex"/>
<ant dir="evictor"/>
- <ant dir="oldevictor"/>
</target>
<target name="clean">
<ant dir="dbmap" target="clean"/>
<ant dir="complex" target="clean"/>
<ant dir="evictor" target="clean"/>
- <ant dir="oldevictor" target="clean"/>
</target>
</project>
diff --git a/java/test/Freeze/oldevictor/.gitignore b/java/test/Freeze/oldevictor/.gitignore
deleted file mode 100644
index 9c39416c539..00000000000
--- a/java/test/Freeze/oldevictor/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-db/*
diff --git a/java/test/Freeze/oldevictor/Client.java b/java/test/Freeze/oldevictor/Client.java
deleted file mode 100644
index f30b38e2e29..00000000000
--- a/java/test/Freeze/oldevictor/Client.java
+++ /dev/null
@@ -1,916 +0,0 @@
-// **********************************************************************
-//
-// Copyright (c) 2003-2009 ZeroC, Inc. All rights reserved.
-//
-// This copy of Ice is licensed to you under the terms described in the
-// ICE_LICENSE file included in this distribution.
-//
-// **********************************************************************
-
-package test.Freeze.oldevictor;
-import test.Freeze.oldevictor.Test.*;
-import java.io.PrintWriter;
-
-public class Client extends test.Util.Application
-{
- private static void
- test(boolean b)
- {
- if(!b)
- {
- throw new RuntimeException();
- }
- }
-
- private static class AMI_Servant_setValueAsyncI extends AMI_Servant_setValueAsync
- {
- public void
- ice_response()
- {
- }
-
- public void
- ice_exception(Ice.LocalException ex)
- {
- }
- }
-
- static class ReadThread extends Thread
- {
- ReadThread(ServantPrx[] servants)
- {
- _servants = servants;
- }
-
- public void run()
- {
- int loops = 10;
- while(loops-- > 0)
- {
- try
- {
- _servants[0].getValue();
- test(false);
- }
- catch(Ice.ObjectNotExistException e)
- {
- // Expected
- }
- catch(Exception e)
- {
- test(false);
- }
-
- for(int i = 1; i < _servants.length; ++i)
- {
- test(_servants[i].getValue() == i);
- }
- }
- }
-
- private ServantPrx[] _servants;
- }
-
- public static final int StateRunning = 0;
- public static final int StateDeactivating = 1;
- public static final int StateDeactivated = 2;
-
- static class ReadForeverThread extends Thread
- {
- ReadForeverThread(ServantPrx[] servants)
- {
- _servants = servants;
- }
-
- public void
- run()
- {
- for(;;)
- {
- try
- {
- for(int i = 0; i < _servants.length; ++i)
- {
- if(getEvictorState() == StateDeactivated)
- {
- _servants[i].slowGetValue();
- test(false);
- }
- else
- {
- test(_servants[i].slowGetValue() == i);
- }
- }
- }
- catch(Ice.SocketException e)
- {
- //
- // Expected
- //
- test(validEx());
- return;
- }
- catch(Ice.LocalException e)
- {
- System.err.println("Caught unexpected : " + e.toString());
- e.printStackTrace();
- test(false);
- return;
- }
- catch(Exception e)
- {
- e.printStackTrace();
- test(false);
- return;
- }
- }
- }
-
- synchronized int
- getEvictorState()
- {
- return _state;
- }
-
- synchronized boolean
- validEx()
- {
- return _state == StateDeactivating || _state == StateDeactivated;
- }
-
- synchronized void
- setEvictorState(int s)
- {
- _state = s;
- }
-
- private ServantPrx[] _servants;
- private int _state = StateRunning;
- }
-
-
- static class AddForeverThread extends Thread
- {
- AddForeverThread(RemoteEvictorPrx evictor, int prefix)
- {
- _evictor = evictor;
- _prefix = "" + prefix;
- }
-
- public void
- run()
- {
- int index = 0;
-
- for(;;)
- {
- try
- {
- String id = _prefix + "-" + index++;
- if(getEvictorState() == StateDeactivated)
- {
- _evictor.createServant(id, 0);
- test(false);
- }
- else
- {
- _evictor.createServant(id, 0);
- }
- }
- catch(EvictorDeactivatedException e)
- {
- //
- // Expected
- //
- test(validEx());
- return;
- }
- catch(Ice.ObjectNotExistException e)
- {
- //
- // Expected
- //
- test(validEx());
- return;
- }
- catch(AlreadyRegisteredException e)
- {
- System.err.println("Caught unexpected AlreadyRegistedException:" + e.toString());
- System.err.println("index is " + index);
- test(false);
- return;
- }
- catch(Ice.LocalException e)
- {
- System.err.println("Caught unexpected : " + e.toString());
- e.printStackTrace();
- test(false);
- return;
- }
- catch(Exception e)
- {
- e.printStackTrace();
- test(false);
- return;
- }
- }
- }
-
- synchronized int
- getEvictorState()
- {
- return _state;
- }
-
- synchronized boolean
- validEx()
- {
- return _state == StateDeactivating || _state == StateDeactivated;
- }
-
- synchronized void
- setEvictorState(int s)
- {
- _state = s;
- }
-
- private RemoteEvictorPrx _evictor;
- private String _prefix;
- private int _state = StateRunning;
- }
-
-
- static class CreateDestroyThread extends Thread
- {
- CreateDestroyThread(RemoteEvictorPrx evictor, int id, int size)
- {
- _evictor = evictor;
- _id = "" + id;
- _size = size;
- }
-
- public void
- run()
- {
- try
- {
- int loops = 50;
- while(loops-- > 0)
- {
- for(int i = 0; i < _size; i++)
- {
- String id = "" + i;
- if(id.equals(_id))
- {
- //
- // Create when odd, destroy when even.
- //
-
- if(loops % 2 == 0)
- {
- ServantPrx servant = _evictor.getServant(id);
- servant.destroy();
-
- //
- // Twice
- //
- try
- {
- servant.destroy();
- test(false);
- }
- catch(Ice.ObjectNotExistException e)
- {
- // Expected
- }
- }
- else
- {
- ServantPrx servant = _evictor.createServant(id, i);
-
- //
- // Twice
- //
- try
- {
- servant = _evictor.createServant(id, 0);
- test(false);
- }
- catch(AlreadyRegisteredException e)
- {
- // Expected
- }
- }
- }
- else
- {
- //
- // Just read/write the value
- //
- ServantPrx servant = _evictor.getServant(id);
- try
- {
- int val = servant.getValue();
- test(val == i || val == -i);
- servant.setValue(-val);
- }
- catch(Ice.ObjectNotExistException e)
- {
- // Expected from time to time
- }
- }
- }
- }
- }
- catch(Exception e)
- {
- //
- // Unexpected!
- //
- test(false);
- }
- }
-
- private RemoteEvictorPrx _evictor;
- private String _id;
- private int _size;
- }
-
- private int
- run(String[] args, PrintWriter out)
- throws AlreadyRegisteredException, NotRegisteredException, EvictorDeactivatedException
- {
- String ref = "factory:default -p 12010";
- Ice.ObjectPrx base = communicator().stringToProxy(ref);
- test(base != null);
- RemoteEvictorFactoryPrx factory = RemoteEvictorFactoryPrxHelper.checkedCast(base);
-
-
- out.print("testing Freeze Evictor... ");
- out.flush();
-
- final int size = 5;
-
- RemoteEvictorPrx evictor = factory.createEvictor("Test");
- evictor.setSize(size);
-
- //
- // Create some servants
- //
- ServantPrx[] servants = new ServantPrx[size];
- for(int i = 0; i < size; i++)
- {
- String id = "" + i;
- servants[i] = evictor.createServant(id, i);
- servants[i].ice_ping();
-
- FacetPrx facet1 = FacetPrxHelper.uncheckedCast(servants[i], "facet1");
- try
- {
- facet1.ice_ping();
- test(false);
- }
- catch(Ice.FacetNotExistException e)
- {
- //
- // Expected
- //
- }
- servants[i].addFacet("facet1", "data");
- facet1.ice_ping();
- facet1 = FacetPrxHelper.checkedCast(servants[i], "facet1");
- test(facet1 != null);
- facet1.setValue(10 * i);
- facet1.addFacet("facet2", "moreData");
- FacetPrx facet2 = FacetPrxHelper.checkedCast(facet1, "facet2");
- test(facet2 != null);
- facet2.setValue(100 * i);
- }
-
- //
- // Evict and verify values.
- //
- evictor.setSize(0);
- evictor.setSize(size);
- for(int i = 0; i < size; i++)
- {
- servants[i].ice_ping();
- test(servants[i].getValue() == i);
- FacetPrx facet1 = FacetPrxHelper.checkedCast(servants[i], "facet1");
- test(facet1 != null);
- test(facet1.getValue() == 10 * i);
- test(facet1.getData().equals("data"));
- FacetPrx facet2 = FacetPrxHelper.checkedCast(facet1, "facet2");
- test(facet2 != null);
- test(facet2.getData().equals("moreData"));
- }
-
- //
- // Mutate servants.
- //
- for(int i = 0; i < size; i++)
- {
- servants[i].setValue(i + 100);
- FacetPrx facet1 = FacetPrxHelper.checkedCast(servants[i], "facet1");
- test(facet1 != null);
- facet1.setValue(10 * i + 100);
- FacetPrx facet2 = FacetPrxHelper.checkedCast(facet1, "facet2");
- test(facet2 != null);
- facet2.setValue(100 * i + 100);
- }
-
- for(int i = 0; i < size; i++)
- {
- test(servants[i].getValue() == i + 100);
- FacetPrx facet1 = FacetPrxHelper.checkedCast(servants[i], "facet1");
- test(facet1 != null);
- test(facet1.getValue() == 10 * i + 100);
- FacetPrx facet2 = FacetPrxHelper.checkedCast(facet1, "facet2");
- test(facet2 != null);
- test(facet2.getValue() == 100 * i + 100);
- }
-
- //
- // Evict and verify values.
- //
- evictor.setSize(0);
- evictor.setSize(size);
- for(int i = 0; i < size; i++)
- {
- test(servants[i].getValue() == i + 100);
- FacetPrx facet1 = FacetPrxHelper.checkedCast(servants[i], "facet1");
- test(facet1 != null);
- test(facet1.getValue() == 10 * i + 100);
- FacetPrx facet2 = FacetPrxHelper.checkedCast(facet1, "facet2");
- test(facet2 != null);
- test(facet2.getValue() == 100 * i + 100);
- }
-
- //
- // Test saving while busy
- //
-
- AMI_Servant_setValueAsyncI setCB = new AMI_Servant_setValueAsyncI();
- for(int i = 0; i < size; i++)
- {
- //
- // Start a mutating operation so that the object is not idle.
- //
- servants[i].setValueAsync_async(setCB, i + 300);
-
- test(servants[i].getValue() == i + 100);
- //
- // This operation modifies the object state but is not saved
- // because the setValueAsync operation is still pending.
- //
- servants[i].setValue(i + 200);
- test(servants[i].getValue() == i + 200);
-
- //
- // Force the response to setValueAsync
- //
- servants[i].releaseAsync();
- test(servants[i].getValue() == i + 300);
- }
-
-
- //
- // Add duplicate facet and catch corresponding exception
- //
- for(int i = 0; i < size; i++)
- {
- try
- {
- servants[i].addFacet("facet1", "foobar");
- test(false);
- }
- catch(AlreadyRegisteredException ex)
- {
- }
- }
-
- //
- // Remove a facet that does not exist
- //
- try
- {
- servants[0].removeFacet("facet3");
- test(false);
- }
- catch(NotRegisteredException ex)
- {
- }
-
- //
- // Remove all facets
- //
- for(int i = 0; i < size; i++)
- {
- servants[i].removeFacet("facet1");
- servants[i].removeFacet("facet2");
- }
-
- evictor.setSize(0);
- evictor.setSize(size);
-
- //
- // Destroy servants and verify ObjectNotExistException.
- //
- for(int i = 0; i < size; i++)
- {
- servants[i].destroy();
- try
- {
- servants[i].getValue();
- test(false);
- }
- catch(Ice.ObjectNotExistException ex)
- {
- // Expected
- }
-
- try
- {
- servants[i].ice_ping();
- test(false);
- }
- catch(Ice.ObjectNotExistException ex)
- {
- // Expected
- }
-
- }
-
- //
- // Allocate space for size servants.
- //
- servants = new ServantPrx[size];
-
- //
- // Recreate servants, set transient value
- //
- for(int i = 0; i < size; i++)
- {
- String id = "" + i;
- servants[i] = evictor.createServant(id, i);
- servants[i].setTransientValue(i);
- }
-
- //
- // Evict
- //
- evictor.saveNow();
- evictor.setSize(0);
- evictor.setSize(size);
-
- //
- // Check the transient value
- //
- for(int i = 0; i < size; i++)
- {
- test(servants[i].getTransientValue() == -1);
- }
-
- //
- // Now with keep
- //
- for(int i = 0; i < size; i++)
- {
- servants[i].keepInCache();
- servants[i].keepInCache();
- servants[i].setTransientValue(i);
- }
- evictor.saveNow();
- evictor.setSize(0);
- evictor.setSize(size);
-
- //
- // Check the transient value
- //
- for(int i = 0; i < size; i++)
- {
- test(servants[i].getTransientValue() == i);
- }
-
- //
- // Again, after one release
- //
- for(int i = 0; i < size; i++)
- {
- servants[i].release();
- }
- evictor.saveNow();
- evictor.setSize(0);
- evictor.setSize(size);
- for(int i = 0; i < size; i++)
- {
- test(servants[i].getTransientValue() == i);
- }
-
- //
- // Again, after a second release
- //
- for(int i = 0; i < size; i++)
- {
- servants[i].release();
- }
- evictor.saveNow();
- evictor.setSize(0);
- evictor.setSize(size);
-
- for(int i = 0; i < size; i++)
- {
- test(servants[i].getTransientValue() == -1);
- }
-
- //
- // Release one more time
- //
- for(int i = 0; i < size; i++)
- {
- try
- {
- servants[i].release();
- test(false);
- }
- catch(NotRegisteredException e)
- {
- // Expected
- }
- }
-
- //
- // Deactivate and recreate evictor, to ensure that servants
- // are restored properly after database close and reopen.
- //
- evictor.deactivate();
- evictor = factory.createEvictor("Test");
- evictor.setSize(size);
- for(int i = 0; i < size; i++)
- {
- String id = "" + i;
- servants[i] = evictor.getServant(id);
- test(servants[i].getValue() == i);
- }
-
-
- //
- // Test concurrent lookups with a smaller evictor
- // size and one missing servant
- //
- evictor.setSize(size / 2);
- servants[0].destroy();
-
- {
- int threadCount = size * 2;
-
- Thread[] threads = new Thread[threadCount];
- for(int i = 0; i < threadCount; i++)
- {
- threads[i] = new ReadThread(servants);
- threads[i].start();
- }
-
- for(int i = 0; i < threadCount; i++)
- {
- for(;;)
- {
- try
- {
- threads[i].join(0);
- break;
- }
- catch(InterruptedException e)
- {
- }
- }
- }
- }
-
- //
- // Clean up.
- //
- evictor.destroyAllServants("");
- evictor.destroyAllServants("facet1");
- evictor.destroyAllServants("facet2");
-
- //
- // CreateDestroy threads
- //
- {
- int threadCount = size;;
-
- Thread[] threads = new Thread[threadCount];
- for(int i = 0; i < threadCount; i++)
- {
- threads[i] = new CreateDestroyThread(evictor, i, size);
- threads[i].start();
- }
-
- for(int i = 0; i < threadCount; i++)
- {
- for(;;)
- {
- try
- {
- threads[i].join(0);
- break;
- }
- catch(InterruptedException e)
- {
- }
- }
- }
-
- //
- // Verify all destroyed
- //
- for(int i = 0; i < size; i++)
- {
- try
- {
- servants[i].getValue();
- test(false);
- }
- catch(Ice.ObjectNotExistException e)
- {
- // Expected
- }
- }
- }
-
- //
- // Recreate servants.
- //
- servants = new ServantPrx[size];
- for(int i = 0; i < size; i++)
- {
- String id = "" + i;
- servants[i] = evictor.createServant(id, i);
- }
-
- //
- // Deactivate in the middle of remote AMD operations
- // (really testing Ice here)
- //
- {
- int threadCount = size;
-
- Thread[] threads = new Thread[threadCount];
- for(int i = 0; i < threadCount; i++)
- {
- threads[i] = new ReadForeverThread(servants);
- threads[i].start();
- }
-
- try
- {
- Thread.currentThread().sleep(500);
- }
- catch(InterruptedException e)
- {
- }
-
- for(int i = 0; i < threadCount; i++)
- {
- ReadForeverThread t = (ReadForeverThread)threads[i];
- t.setEvictorState(StateDeactivating);
- }
- evictor.deactivate();
- for(int i = 0; i < threadCount; i++)
- {
- ReadForeverThread t = (ReadForeverThread)threads[i];
- t.setEvictorState(StateDeactivated);
- }
-
- for(int i = 0; i < threadCount; i++)
- {
- for(;;)
- {
- try
- {
- threads[i].join(0);
- break;
- }
- catch(InterruptedException e)
- {
- }
- }
- }
- }
-
- //
- // Resurrect
- //
- evictor = factory.createEvictor("Test");
- evictor.destroyAllServants("");
-
- //
- // Deactivate in the middle of adds
- //
- {
- int threadCount = size;
-
- Thread[] threads = new Thread[threadCount];
- for(int i = 0; i < threadCount; i++)
- {
- threads[i] = new AddForeverThread(evictor, i);
- threads[i].start();
- }
-
- try
- {
- Thread.currentThread().sleep(500);
- }
- catch(InterruptedException e)
- {
- }
-
- for(int i = 0; i < threadCount; i++)
- {
- AddForeverThread t = (AddForeverThread)threads[i];
- t.setEvictorState(StateDeactivating);
- }
- evictor.deactivate();
- for(int i = 0; i < threadCount; i++)
- {
- AddForeverThread t = (AddForeverThread)threads[i];
- t.setEvictorState(StateDeactivated);
- }
-
- for(int i = 0; i < threadCount; i++)
- {
- for(;;)
- {
- try
- {
- threads[i].join(0);
- break;
- }
- catch(InterruptedException e)
- {
- }
- }
- }
- }
-
-
- //
- // Clean up.
- //
- evictor = factory.createEvictor("Test");
- evictor.destroyAllServants("");
- evictor.deactivate();
-
-
- out.println("ok");
-
- factory.shutdown();
-
- return 0;
- }
-
- public int
- run(String[] args)
- {
- PrintWriter out = getWriter();
- int status = 0;
- try
- {
- status = run(args, out);
- }
- catch(AlreadyRegisteredException ex)
- {
- ex.printStackTrace(out);
- status = 1;
- }
- catch(NotRegisteredException ex)
- {
- ex.printStackTrace(out);
- status = 1;
- }
- catch(EvictorDeactivatedException ex)
- {
- ex.printStackTrace(out);
- status = 1;
- }
- return status;
- }
-
- protected Ice.InitializationData getInitData(Ice.StringSeqHolder argsH)
- {
- Ice.InitializationData initData = new Ice.InitializationData();
- initData.properties = Ice.Util.createProperties(argsH);
- initData.properties.setProperty("Ice.Package.Test", "test.Freeze.oldevictor");
- return initData;
- }
-
- public static void main(String[] args)
- {
- Client c = new Client();
- int status = c.main("Client", args);
-
- System.gc();
- System.exit(status);
- }
-}
diff --git a/java/test/Freeze/oldevictor/FacetI.java b/java/test/Freeze/oldevictor/FacetI.java
deleted file mode 100644
index deb857b3763..00000000000
--- a/java/test/Freeze/oldevictor/FacetI.java
+++ /dev/null
@@ -1,43 +0,0 @@
-// **********************************************************************
-//
-// Copyright (c) 2003-2009 ZeroC, Inc. All rights reserved.
-//
-// This copy of Ice is licensed to you under the terms described in the
-// ICE_LICENSE file included in this distribution.
-//
-// **********************************************************************
-
-package test.Freeze.oldevictor;
-import test.Freeze.oldevictor.Test.*;
-
-public class FacetI extends ServantI implements _FacetOperations
-{
- FacetI(Facet tie)
- {
- super(tie);
- }
-
- FacetI(Servant tie, RemoteEvictorI remoteEvictor, Freeze.BackgroundSaveEvictor evictor, int value, String data)
- {
- super(tie, remoteEvictor, evictor, value);
- ((Facet)_tie).data = data;
- }
-
- public String
- getData(Ice.Current current)
- {
- synchronized(_tie)
- {
- return ((Facet)_tie).data;
- }
- }
-
- public void
- setData(String data, Ice.Current current)
- {
- synchronized(_tie)
- {
- ((Facet)_tie).data = data;
- }
- }
-}
diff --git a/java/test/Freeze/oldevictor/RemoteEvictorFactoryI.java b/java/test/Freeze/oldevictor/RemoteEvictorFactoryI.java
deleted file mode 100644
index 0e99ab62388..00000000000
--- a/java/test/Freeze/oldevictor/RemoteEvictorFactoryI.java
+++ /dev/null
@@ -1,36 +0,0 @@
-// **********************************************************************
-//
-// Copyright (c) 2003-2009 ZeroC, Inc. All rights reserved.
-//
-// This copy of Ice is licensed to you under the terms described in the
-// ICE_LICENSE file included in this distribution.
-//
-// **********************************************************************
-
-package test.Freeze.oldevictor;
-import test.Freeze.oldevictor.Test.*;
-
-public final class RemoteEvictorFactoryI extends _RemoteEvictorFactoryDisp
-{
- RemoteEvictorFactoryI(String envName)
- {
- _envName = envName;
- }
-
-
- public RemoteEvictorPrx
- createEvictor(String name, Ice.Current current)
- {
- RemoteEvictorI remoteEvictor = new RemoteEvictorI(current.adapter.getCommunicator(), _envName, name);
- return RemoteEvictorPrxHelper.
- uncheckedCast(current.adapter.add(remoteEvictor, current.adapter.getCommunicator().stringToIdentity(name)));
- }
-
- public void
- shutdown(Ice.Current current)
- {
- current.adapter.getCommunicator().shutdown();
- }
-
- private String _envName;
-}
diff --git a/java/test/Freeze/oldevictor/RemoteEvictorI.java b/java/test/Freeze/oldevictor/RemoteEvictorI.java
deleted file mode 100644
index 24301705ee0..00000000000
--- a/java/test/Freeze/oldevictor/RemoteEvictorI.java
+++ /dev/null
@@ -1,141 +0,0 @@
-// **********************************************************************
-//
-// Copyright (c) 2003-2009 ZeroC, Inc. All rights reserved.
-//
-// This copy of Ice is licensed to you under the terms described in the
-// ICE_LICENSE file included in this distribution.
-//
-// **********************************************************************
-
-package test.Freeze.oldevictor;
-import test.Freeze.oldevictor.Test.*;
-
-public final class RemoteEvictorI extends _RemoteEvictorDisp
-{
- static class Initializer implements Freeze.ServantInitializer
- {
- public void
- initialize(Ice.ObjectAdapter adapter, Ice.Identity ident, String facet, Ice.Object servant)
- {
- if(facet.length() == 0)
- {
- ServantI servantImpl = (ServantI) ((_ServantTie) servant).ice_delegate();
- servantImpl.init(_remoteEvictor, _evictor);
- }
- else
- {
- ServantI servantImpl = (ServantI) ((_FacetTie) servant).ice_delegate();
- servantImpl.init(_remoteEvictor, _evictor);
- }
- }
-
- void init(RemoteEvictorI remoteEvictor, Freeze.BackgroundSaveEvictor evictor)
- {
- _remoteEvictor = remoteEvictor;
- _evictor = evictor;
- }
-
- private RemoteEvictorI _remoteEvictor;
- private Freeze.BackgroundSaveEvictor _evictor;
- }
-
-
- RemoteEvictorI(Ice.Communicator communicator, String envName, String category)
- {
- _category = category;
-
- //
- // NOTE: COMPILERBUG: The timeout here is required for MacOS X.
- //
- _evictorAdapter = communicator.createObjectAdapterWithEndpoints(
- java.util.UUID.randomUUID().toString(), "default -t 30000");
-
- Initializer initializer = new Initializer();
-
- _evictor = Freeze.Util.createBackgroundSaveEvictor(_evictorAdapter, envName, category, initializer, null, true);
- initializer.init(this, _evictor);
-
- _evictorAdapter.addServantLocator(_evictor, category);
- _evictorAdapter.activate();
- }
-
- public void
- setSize(int size, Ice.Current current)
- {
- _evictor.setSize(size);
- }
-
- public ServantPrx
- createServant(String id, int value, Ice.Current current)
- throws AlreadyRegisteredException, EvictorDeactivatedException
- {
- Ice.Identity ident = new Ice.Identity();
- ident.category = _category;
- ident.name = id;
- _ServantTie tie = new _ServantTie();
- tie.ice_delegate(new ServantI(tie, this, _evictor, value));
- try
- {
- return ServantPrxHelper.uncheckedCast(_evictor.add(tie, ident));
- }
- catch(Ice.AlreadyRegisteredException e)
- {
- throw new AlreadyRegisteredException();
- }
- catch(Ice.ObjectAdapterDeactivatedException e)
- {
- throw new EvictorDeactivatedException();
- }
- catch(Freeze.EvictorDeactivatedException e)
- {
- throw new EvictorDeactivatedException();
- }
- catch(Ice.LocalException e)
- {
- System.out.println("Throwing " + e.toString());
- throw e;
- }
- }
-
- public ServantPrx
- getServant(String id, Ice.Current current)
- {
- Ice.Identity ident = new Ice.Identity();
- ident.category = _category;
- ident.name = id;
- return ServantPrxHelper.uncheckedCast(_evictorAdapter.createProxy(ident));
- }
-
- public void
- saveNow(Ice.Current current)
- {
- _evictor.getIterator("", 1);
- }
-
- public void
- deactivate(Ice.Current current)
- {
- _evictorAdapter.destroy();
- current.adapter.remove(current.adapter.getCommunicator().stringToIdentity(_category));
- }
-
- public void
- destroyAllServants(String facet, Ice.Current current)
- {
- //
- // Only for test purpose: don't use such a small value in
- // a real application!
- //
- int batchSize = 2;
-
- Freeze.EvictorIterator p = _evictor.getIterator(facet, batchSize);
- while(p.hasNext())
- {
- _evictor.remove((Ice.Identity) p.next());
- }
- }
-
- private String _category;
- private Freeze.BackgroundSaveEvictor _evictor;
- private Ice.ObjectAdapter _evictorAdapter;
-}
diff --git a/java/test/Freeze/oldevictor/ServantI.java b/java/test/Freeze/oldevictor/ServantI.java
deleted file mode 100644
index a4e58c34018..00000000000
--- a/java/test/Freeze/oldevictor/ServantI.java
+++ /dev/null
@@ -1,201 +0,0 @@
-// **********************************************************************
-//
-// Copyright (c) 2003-2009 ZeroC, Inc. All rights reserved.
-//
-// This copy of Ice is licensed to you under the terms described in the
-// ICE_LICENSE file included in this distribution.
-//
-// **********************************************************************
-
-package test.Freeze.oldevictor;
-import test.Freeze.oldevictor.Test.*;
-
-public class ServantI implements _ServantOperations
-{
- static class DelayedResponse extends Thread
- {
- DelayedResponse(AMD_Servant_slowGetValue cb, int val)
- {
- _cb = cb;
- _val = val;
- }
-
- public void
- run()
- {
- try
- {
- sleep(500);
- }
- catch(InterruptedException e)
- {
- // Ignored
- }
- _cb.ice_response(_val);
- }
-
- private AMD_Servant_slowGetValue _cb;
- private int _val;
- }
-
-
- ServantI(Servant tie)
- {
- _tie = tie;
- }
-
- ServantI(Servant tie, RemoteEvictorI remoteEvictor, Freeze.BackgroundSaveEvictor evictor, int value)
- {
- _tie = tie;
- _remoteEvictor = remoteEvictor;
- _evictor = evictor;
- _tie.value = value;
- }
-
- void
- init(RemoteEvictorI remoteEvictor, Freeze.BackgroundSaveEvictor evictor)
- {
- _remoteEvictor = remoteEvictor;
- _evictor = evictor;
- }
-
- public void
- destroy(Ice.Current current)
- {
- _evictor.remove(current.id);
- }
-
- public int
- getValue(Ice.Current current)
- {
- synchronized(_tie)
- {
- return _tie.value;
- }
- }
-
- public void
- slowGetValue_async(AMD_Servant_slowGetValue cb, Ice.Current current)
- {
- synchronized(_tie)
- {
- Thread t = new DelayedResponse(cb, _tie.value);
- t.setDaemon(true);
- t.start();
- }
- }
-
- public void
- setValue(int value, Ice.Current current)
- {
- synchronized(_tie)
- {
- _tie.value = value;
- }
- }
-
- public void
- setValueAsync_async(AMD_Servant_setValueAsync __cb, int value, Ice.Current current)
- {
- synchronized(_tie)
- {
- _setValueAsyncCB = __cb;
- _setValueAsyncValue = value;
- _tie.notify();
- }
- }
-
- public void
- releaseAsync(Ice.Current current)
- {
- synchronized(_tie)
- {
- while(_setValueAsyncCB == null)
- {
- try
- {
- _tie.wait();
- }
- catch(InterruptedException ie)
- {
- break;
- }
- }
-
- _tie.value = _setValueAsyncValue;
- _setValueAsyncCB.ice_response();
- _setValueAsyncCB = null;
- }
- }
-
- public void
- addFacet(String name, String data, Ice.Current current)
- throws AlreadyRegisteredException
- {
- _FacetTie tie = new _FacetTie();
- tie.ice_delegate(new FacetI(tie, _remoteEvictor, _evictor, 0, data));
-
- try
- {
- _evictor.addFacet(tie, current.id, name);
- }
- catch(Ice.AlreadyRegisteredException ex)
- {
- throw new AlreadyRegisteredException();
- }
- }
-
- public void
- removeFacet(String name, Ice.Current current)
- throws NotRegisteredException
- {
- try
- {
- _evictor.removeFacet(current.id, name);
- }
- catch(Ice.NotRegisteredException ex)
- {
- throw new NotRegisteredException();
- }
-
- }
-
- public synchronized int
- getTransientValue(Ice.Current current)
- {
- return _transientValue;
- }
-
- public synchronized void
- setTransientValue(int val, Ice.Current current)
- {
- _transientValue = val;
- }
-
- public void
- keepInCache(Ice.Current current)
- {
- _evictor.keep(current.id);
- }
-
- public void
- release(Ice.Current current)
- throws NotRegisteredException
- {
- try
- {
- _evictor.release(current.id);
- }
- catch(Ice.NotRegisteredException e)
- {
- throw new NotRegisteredException();
- }
- }
-
- protected RemoteEvictorI _remoteEvictor;
- protected Freeze.BackgroundSaveEvictor _evictor;
- protected AMD_Servant_setValueAsync _setValueAsyncCB;
- protected int _setValueAsyncValue;
- protected Servant _tie;
- private int _transientValue = -1;
-}
diff --git a/java/test/Freeze/oldevictor/Server.java b/java/test/Freeze/oldevictor/Server.java
deleted file mode 100644
index da652fdac82..00000000000
--- a/java/test/Freeze/oldevictor/Server.java
+++ /dev/null
@@ -1,88 +0,0 @@
-// **********************************************************************
-//
-// Copyright (c) 2003-2009 ZeroC, Inc. All rights reserved.
-//
-// This copy of Ice is licensed to you under the terms described in the
-// ICE_LICENSE file included in this distribution.
-//
-// **********************************************************************
-
-package test.Freeze.oldevictor;
-import test.Freeze.oldevictor.Test.*;
-
-public class Server extends test.Util.Application
-{
- static class ServantFactory implements Ice.ObjectFactory
- {
- public Ice.Object
- create(String type)
- {
- assert(type.equals("::Test::Servant"));
- _ServantTie tie = new _ServantTie();
- tie.ice_delegate(new ServantI(tie));
- return tie;
- }
-
- public void
- destroy()
- {
- }
- }
-
- static class FacetFactory implements Ice.ObjectFactory
- {
- public Ice.Object
- create(String type)
- {
- assert(type.equals("::Test::Facet"));
- _FacetTie tie = new _FacetTie();
- tie.ice_delegate(new FacetI(tie));
- return tie;
- }
-
- public void
- destroy()
- {
- }
- }
-
- public int
- run(String[] args)
- {
- Ice.Communicator communicator = communicator();
- Ice.ObjectAdapter adapter = communicator.createObjectAdapter("Evictor");
-
- RemoteEvictorFactoryI factory = new RemoteEvictorFactoryI("db");
- adapter.add(factory, communicator.stringToIdentity("factory"));
-
- Ice.ObjectFactory servantFactory = new ServantFactory();
- communicator.addObjectFactory(servantFactory, "::Test::Servant");
-
- Ice.ObjectFactory facetFactory = new FacetFactory();
- communicator.addObjectFactory(facetFactory, "::Test::Facet");
-
- adapter.activate();
-
- communicator.waitForShutdown();
-
- return 0;
- }
-
- protected Ice.InitializationData getInitData(Ice.StringSeqHolder argsH)
- {
- Ice.InitializationData initData = new Ice.InitializationData();
- initData.properties = Ice.Util.createProperties(argsH);
- initData.properties.setProperty("Evictor.Endpoints", "default -p 12010");
- initData.properties.setProperty("Ice.Package.Test", "test.Freeze.oldevictor");
- return initData;
- }
-
- public static void main(String[] args)
- {
- Server c = new Server();
- int status = c.main("Server", args);
-
- System.gc();
- System.exit(status);
- }
-}
diff --git a/java/test/Freeze/oldevictor/Test.ice b/java/test/Freeze/oldevictor/Test.ice
deleted file mode 100644
index 9aee35acfe7..00000000000
--- a/java/test/Freeze/oldevictor/Test.ice
+++ /dev/null
@@ -1,83 +0,0 @@
-// **********************************************************************
-//
-// Copyright (c) 2003-2009 ZeroC, Inc. All rights reserved.
-//
-// This copy of Ice is licensed to you under the terms described in the
-// ICE_LICENSE file included in this distribution.
-//
-// **********************************************************************
-
-#ifndef TEST_ICE
-#define TEST_ICE
-
-[["java:package:test.Freeze.oldevictor"]]
-module Test
-{
-
-exception AlreadyRegisteredException
-{
-};
-
-exception NotRegisteredException
-{
-};
-
-exception EvictorDeactivatedException
-{
-};
-
-class Servant
-{
- idempotent int getValue();
- ["amd"] idempotent int slowGetValue();
-
- void setValue(int value);
-
- ["ami", "amd"] void setValueAsync(int value);
- idempotent void releaseAsync();
-
- idempotent void addFacet(string name, string data) throws AlreadyRegisteredException;
- idempotent void removeFacet(string name) throws NotRegisteredException;
-
- idempotent int getTransientValue();
- void setTransientValue(int value);
- void keepInCache();
- void release() throws NotRegisteredException;
-
- void destroy();
-
- int value;
-};
-
-class Facet extends Servant
-{
- idempotent string getData();
- void setData(string data);
-
- string data;
-};
-
-interface RemoteEvictor
-{
- void setSize(int size);
-
- Servant* createServant(string id, int value)
- throws AlreadyRegisteredException, EvictorDeactivatedException;
-
- Servant* getServant(string id);
-
- void saveNow();
-
- void deactivate();
- void destroyAllServants(string facet);
-};
-
-interface RemoteEvictorFactory
-{
- RemoteEvictor* createEvictor(string name);
- void shutdown();
-};
-
-};
-
-#endif
diff --git a/java/test/Freeze/oldevictor/build.xml b/java/test/Freeze/oldevictor/build.xml
deleted file mode 100644
index 53e3da828d6..00000000000
--- a/java/test/Freeze/oldevictor/build.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-<!--
- **********************************************************************
-
- Copyright (c) 2003-2009 ZeroC, Inc. All rights reserved.
-
- This copy of Ice is licensed to you under the terms described in the
- ICE_LICENSE file included in this distribution.
-
- **********************************************************************
--->
-
-<project name="test_Freeze_evictor" default="all" basedir=".">
-
- <!-- set global properties for this build -->
- <property name="top.dir" value="../../.."/>
-
- <!-- import common definitions -->
- <import file="${top.dir}/config/common.xml"/>
-
- <target name="all"/>
-
- <target name="clean">
- <delete dir="${class.dir}"/>
- <delete dir="${generated.dir}"/>
- <delete>
- <fileset dir="db" includes="log.*"/>
- <fileset dir="db" includes="__catalog*"/>
- <fileset dir="db" includes="Test"/>
- </delete>
- </target>
-
-</project>
diff --git a/java/test/Freeze/oldevictor/config b/java/test/Freeze/oldevictor/config
deleted file mode 100644
index d456ae86464..00000000000
--- a/java/test/Freeze/oldevictor/config
+++ /dev/null
@@ -1,10 +0,0 @@
-Freeze.Evictor.db.Test.SaveSizeTrigger=6
-Freeze.Evictor.db.Test.SavePeriod=2
-
-#Freeze.Trace.Evictor=1
-#Freeze.Trace.DbEnv=3
-
-Ice.ThreadPool.Server.SizeMax=20
-Ice.ThreadPool.Server.SizeWarn=0
-
-Freeze.Evictor.UseNonmutating=1
diff --git a/java/test/Freeze/oldevictor/db/.gitignore b/java/test/Freeze/oldevictor/db/.gitignore
deleted file mode 100644
index 39af5887579..00000000000
--- a/java/test/Freeze/oldevictor/db/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-# Dummy file, so that git retains this otherwise empty directory.
diff --git a/java/test/Freeze/oldevictor/run.py b/java/test/Freeze/oldevictor/run.py
deleted file mode 100755
index e5a3fbac28f..00000000000
--- a/java/test/Freeze/oldevictor/run.py
+++ /dev/null
@@ -1,30 +0,0 @@
-#!/usr/bin/env python
-# **********************************************************************
-#
-# Copyright (c) 2003-2009 ZeroC, Inc. All rights reserved.
-#
-# This copy of Ice is licensed to you under the terms described in the
-# ICE_LICENSE file included in this distribution.
-#
-# **********************************************************************
-
-import os, sys
-
-path = [ ".", "..", "../..", "../../..", "../../../.." ]
-head = os.path.dirname(sys.argv[0])
-if len(head) > 0:
- path = [os.path.join(head, p) for p in path]
-path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ]
-if len(path) == 0:
- raise "can't find toplevel directory!"
-sys.path.append(os.path.join(path[0]))
-from scripts import *
-
-dbdir = os.path.join(os.getcwd(), "db")
-TestUtil.cleanDbDir(dbdir)
-
-testOptions = " --Freeze.DbEnv.db.DbHome=%s --Ice.Config=%s" % (dbdir, os.path.join(os.getcwd(), "config"))
-
-TestUtil.clientServerTest(testOptions, testOptions)
-
-TestUtil.cleanup()