summaryrefslogtreecommitdiff
path: root/java/demo/Manual/evictor_filesystem
diff options
context:
space:
mode:
authorMatthew Newhook <matthew@zeroc.com>2015-03-18 12:58:16 -0230
committerMatthew Newhook <matthew@zeroc.com>2015-03-18 12:58:16 -0230
commit9b7668c7c92cf9cb311fe444cdddb489cd2a219d (patch)
tree5016567c58c81f5654e9d01935e199c6bf4761d2 /java/demo/Manual/evictor_filesystem
parentVS add-in & build updates: (diff)
downloadice-9b7668c7c92cf9cb311fe444cdddb489cd2a219d.tar.bz2
ice-9b7668c7c92cf9cb311fe444cdddb489cd2a219d.tar.xz
ice-9b7668c7c92cf9cb311fe444cdddb489cd2a219d.zip
Removed demos.
Moved demoscript to distribution.
Diffstat (limited to 'java/demo/Manual/evictor_filesystem')
-rw-r--r--java/demo/Manual/evictor_filesystem/.externalToolBuilders/book.demo.evictor_filesystem.slice.launch17
-rw-r--r--java/demo/Manual/evictor_filesystem/.gitignore1
-rw-r--r--java/demo/Manual/evictor_filesystem/Client.java50
-rw-r--r--java/demo/Manual/evictor_filesystem/DirectoryI.java170
-rw-r--r--java/demo/Manual/evictor_filesystem/FileI.java80
-rw-r--r--java/demo/Manual/evictor_filesystem/Filesystem.ice63
-rw-r--r--java/demo/Manual/evictor_filesystem/Grammar.java202
-rw-r--r--java/demo/Manual/evictor_filesystem/NodeFactory.java38
-rw-r--r--java/demo/Manual/evictor_filesystem/Parser.java349
-rw-r--r--java/demo/Manual/evictor_filesystem/PersistentFilesystem.ice38
-rw-r--r--java/demo/Manual/evictor_filesystem/README11
-rw-r--r--java/demo/Manual/evictor_filesystem/Scanner.java283
-rw-r--r--java/demo/Manual/evictor_filesystem/Server.java82
-rw-r--r--java/demo/Manual/evictor_filesystem/Token.java40
-rw-r--r--java/demo/Manual/evictor_filesystem/config.client28
-rw-r--r--java/demo/Manual/evictor_filesystem/config.server49
-rw-r--r--java/demo/Manual/evictor_filesystem/db/.gitignore1
-rwxr-xr-xjava/demo/Manual/evictor_filesystem/expect.py34
18 files changed, 0 insertions, 1536 deletions
diff --git a/java/demo/Manual/evictor_filesystem/.externalToolBuilders/book.demo.evictor_filesystem.slice.launch b/java/demo/Manual/evictor_filesystem/.externalToolBuilders/book.demo.evictor_filesystem.slice.launch
deleted file mode 100644
index 0ce604434d2..00000000000
--- a/java/demo/Manual/evictor_filesystem/.externalToolBuilders/book.demo.evictor_filesystem.slice.launch
+++ /dev/null
@@ -1,17 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<launchConfiguration type="org.eclipse.ant.AntBuilderLaunchConfigurationType">
-<stringAttribute key="org.eclipse.ant.ui.ATTR_ANT_AUTO_TARGETS" value="generate,"/>
-<stringAttribute key="org.eclipse.ant.ui.ATTR_ANT_CLEAN_TARGETS" value="clean,"/>
-<stringAttribute key="org.eclipse.ant.ui.ATTR_ANT_MANUAL_TARGETS" value="generate,"/>
-<booleanAttribute key="org.eclipse.ant.ui.ATTR_TARGETS_UPDATED" value="true"/>
-<booleanAttribute key="org.eclipse.ant.ui.DEFAULT_VM_INSTALL" value="false"/>
-<stringAttribute key="org.eclipse.debug.core.ATTR_REFRESH_SCOPE" value="${container}"/>
-<booleanAttribute key="org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND" value="false"/>
-<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.eclipse.ant.ui.AntClasspathProvider"/>
-<booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="true"/>
-<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="demo.book.evictor_filesystem"/>
-<stringAttribute key="org.eclipse.ui.externaltools.ATTR_BUILD_SCOPE" value="${working_set:&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&#10;&lt;resources&gt;&#10;&lt;item path=&quot;/demo.book.evictor_filesystem/Filesystem.ice&quot; type=&quot;1&quot;/&gt;&#10;&lt;item path=&quot;/demo.book.evictor_filesystem/PersistentFilesystem.ice&quot; type=&quot;1&quot;/&gt;&#10;&lt;/resources&gt;}"/>
-<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${workspace_loc:/demo.book.evictor_filesystem/build.xml}"/>
-<stringAttribute key="org.eclipse.ui.externaltools.ATTR_RUN_BUILD_KINDS" value="incremental,auto,clean"/>
-<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED" value="true"/>
-</launchConfiguration>
diff --git a/java/demo/Manual/evictor_filesystem/.gitignore b/java/demo/Manual/evictor_filesystem/.gitignore
deleted file mode 100644
index 9c39416c539..00000000000
--- a/java/demo/Manual/evictor_filesystem/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-db/*
diff --git a/java/demo/Manual/evictor_filesystem/Client.java b/java/demo/Manual/evictor_filesystem/Client.java
deleted file mode 100644
index 4f01c9e0787..00000000000
--- a/java/demo/Manual/evictor_filesystem/Client.java
+++ /dev/null
@@ -1,50 +0,0 @@
-// **********************************************************************
-//
-// Copyright (c) 2003-2015 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 Filesystem.*;
-
-public class Client extends Ice.Application
-{
- @Override
- public int
- run(String[] args)
- {
- //
- // Terminate cleanly on receipt of a signal.
- //
- shutdownOnInterrupt();
-
- //
- // Create a proxy for the root directory
- //
- DirectoryPrx rootDir = DirectoryPrxHelper.checkedCast(communicator().propertyToProxy("RootDir.Proxy"));
- if(rootDir == null)
- {
- throw new Error("Client: invalid proxy");
- }
-
- Parser p = new Parser(rootDir);
- return p.parse();
- }
-
- static public void
- main(String[] args)
- {
- Client app = new Client();
- app.main("demo.book.evictor_filesystem.Client", args, "config.client");
- }
-
- static private class Error extends RuntimeException
- {
- public Error(String msg)
- {
- super(msg);
- }
- }
-}
diff --git a/java/demo/Manual/evictor_filesystem/DirectoryI.java b/java/demo/Manual/evictor_filesystem/DirectoryI.java
deleted file mode 100644
index 0087731b0cf..00000000000
--- a/java/demo/Manual/evictor_filesystem/DirectoryI.java
+++ /dev/null
@@ -1,170 +0,0 @@
-// **********************************************************************
-//
-// Copyright (c) 2003-2015 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 Filesystem.*;
-
-public final class DirectoryI extends PersistentDirectory
-{
- public
- DirectoryI()
- {
- _destroyed = false;
- nodes = new java.util.HashMap<java.lang.String, NodeDesc>();
- }
-
- @Override
- public synchronized String
- name(Ice.Current current)
- {
- if(_destroyed)
- {
- throw new Ice.ObjectNotExistException(current.id, current.facet, current.operation);
- }
-
- return nodeName;
- }
-
- @Override
- public void
- destroy(Ice.Current current)
- throws PermissionDenied
- {
- if(parent == null)
- {
- throw new PermissionDenied("Cannot destroy root directory");
- }
-
- synchronized(this)
- {
- if(_destroyed)
- {
- throw new Ice.ObjectNotExistException(current.id, current.facet, current.operation);
- }
- if(!nodes.isEmpty())
- {
- throw new PermissionDenied("Cannot destroy non-empty directory");
- }
- _destroyed = true;
- }
-
- //
- // Because we use a transactional evictor, these updates are guaranteed to be atomic.
- //
- parent.removeNode(nodeName);
- _evictor.remove(current.id);
- }
-
- @Override
- public synchronized NodeDesc[]
- list(Ice.Current current)
- {
- if(_destroyed)
- {
- throw new Ice.ObjectNotExistException(current.id, current.facet, current.operation);
- }
-
- NodeDesc[] result = new NodeDesc[nodes.size()];
- int i = 0;
- java.util.Iterator<NodeDesc> p = nodes.values().iterator();
- while(p.hasNext())
- {
- result[i++] = p.next();
- }
- return result;
- }
-
- @Override
- public synchronized NodeDesc
- find(String name, Ice.Current current)
- throws NoSuchName
- {
- if(_destroyed)
- {
- throw new Ice.ObjectNotExistException(current.id, current.facet, current.operation);
- }
-
- if(!nodes.containsKey(name))
- {
- throw new NoSuchName(name);
- }
-
- return nodes.get(name);
- }
-
- @Override
- public synchronized DirectoryPrx
- createDirectory(String name, Ice.Current current)
- throws NameInUse
- {
- if(_destroyed)
- {
- throw new Ice.ObjectNotExistException(current.id, current.facet, current.operation);
- }
-
- if(name.length() == 0 || nodes.containsKey(name))
- {
- throw new NameInUse(name);
- }
-
- Ice.Identity id = current.adapter.getCommunicator().stringToIdentity(java.util.UUID.randomUUID().toString());
- PersistentDirectory dir = new DirectoryI();
- dir.nodeName = name;
- dir.parent = PersistentDirectoryPrxHelper.uncheckedCast(current.adapter.createProxy(current.id));
- DirectoryPrx proxy = DirectoryPrxHelper.uncheckedCast(_evictor.add(dir, id));
-
- NodeDesc nd = new NodeDesc();
- nd.name = name;
- nd.type = NodeType.DirType;
- nd.proxy = proxy;
- nodes.put(name, nd);
-
- return proxy;
- }
-
- @Override
- public synchronized FilePrx
- createFile(String name, Ice.Current current)
- throws NameInUse
- {
- if(_destroyed)
- {
- throw new Ice.ObjectNotExistException(current.id, current.facet, current.operation);
- }
-
- if(name.length() == 0 || nodes.containsKey(name))
- {
- throw new NameInUse(name);
- }
-
- Ice.Identity id = current.adapter.getCommunicator().stringToIdentity(java.util.UUID.randomUUID().toString());
- PersistentFile file = new FileI();
- file.nodeName = name;
- file.parent = PersistentDirectoryPrxHelper.uncheckedCast(current.adapter.createProxy(current.id));
- FilePrx proxy = FilePrxHelper.uncheckedCast(_evictor.add(file, id));
-
- NodeDesc nd = new NodeDesc();
- nd.name = name;
- nd.type = NodeType.FileType;
- nd.proxy = proxy;
- nodes.put(name, nd);
-
- return proxy;
- }
-
- @Override
- public synchronized void
- removeNode(String name, Ice.Current current)
- {
- assert(nodes.containsKey(name));
- nodes.remove(name);
- }
-
- public static Freeze.Evictor _evictor;
- private boolean _destroyed;
-}
diff --git a/java/demo/Manual/evictor_filesystem/FileI.java b/java/demo/Manual/evictor_filesystem/FileI.java
deleted file mode 100644
index 7f269e3b514..00000000000
--- a/java/demo/Manual/evictor_filesystem/FileI.java
+++ /dev/null
@@ -1,80 +0,0 @@
-// **********************************************************************
-//
-// Copyright (c) 2003-2015 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 Filesystem.*;
-
-public final class FileI extends PersistentFile
-{
- public
- FileI()
- {
- _destroyed = false;
- }
-
- @Override
- public synchronized String
- name(Ice.Current current)
- {
- if(_destroyed)
- {
- throw new Ice.ObjectNotExistException(current.id, current.facet, current.operation);
- }
-
- return nodeName;
- }
-
- @Override
- public void
- destroy(Ice.Current current)
- throws PermissionDenied
- {
- synchronized(this)
- {
- if(_destroyed)
- {
- throw new Ice.ObjectNotExistException(current.id, current.facet, current.operation);
- }
- _destroyed = true;
- }
-
- //
- // Because we use a transactional evictor, these updates are guaranteed to be atomic.
- //
- parent.removeNode(nodeName);
- _evictor.remove(current.id);
- }
-
- @Override
- public synchronized String[]
- read(Ice.Current current)
- {
- if(_destroyed)
- {
- throw new Ice.ObjectNotExistException(current.id, current.facet, current.operation);
- }
-
- return text.clone();
- }
-
- @Override
- public synchronized void
- write(String[] text, Ice.Current current)
- throws GenericError
- {
- if(_destroyed)
- {
- throw new Ice.ObjectNotExistException(current.id, current.facet, current.operation);
- }
-
- this.text = text;
- }
-
- public static Freeze.Evictor _evictor;
- private boolean _destroyed;
-}
diff --git a/java/demo/Manual/evictor_filesystem/Filesystem.ice b/java/demo/Manual/evictor_filesystem/Filesystem.ice
deleted file mode 100644
index a9c863544f1..00000000000
--- a/java/demo/Manual/evictor_filesystem/Filesystem.ice
+++ /dev/null
@@ -1,63 +0,0 @@
-// **********************************************************************
-//
-// Copyright (c) 2003-2015 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.
-//
-// **********************************************************************
-
-#pragma once
-
-module Filesystem
-{
- exception GenericError
- {
- string reason;
- };
- exception PermissionDenied extends GenericError {};
- exception NameInUse extends GenericError {};
- exception NoSuchName extends GenericError {};
-
- interface Node
- {
- idempotent string name();
-
- ["freeze:write"]
- void destroy() throws PermissionDenied;
- };
-
- sequence<string> Lines;
-
- interface File extends Node
- {
- idempotent Lines read();
-
- ["freeze:write"]
- idempotent void write(Lines text) throws GenericError;
- };
-
- enum NodeType { DirType, FileType };
-
- struct NodeDesc
- {
- string name;
- NodeType type;
- Node* proxy;
- };
-
- sequence<NodeDesc> NodeDescSeq;
-
- interface Directory extends Node
- {
- idempotent NodeDescSeq list();
-
- idempotent NodeDesc find(string name) throws NoSuchName;
-
- ["freeze:write"]
- File* createFile(string name) throws NameInUse;
-
- ["freeze:write"]
- Directory* createDirectory(string name) throws NameInUse;
- };
-};
diff --git a/java/demo/Manual/evictor_filesystem/Grammar.java b/java/demo/Manual/evictor_filesystem/Grammar.java
deleted file mode 100644
index 57f046c62e3..00000000000
--- a/java/demo/Manual/evictor_filesystem/Grammar.java
+++ /dev/null
@@ -1,202 +0,0 @@
-// **********************************************************************
-//
-// Copyright (c) 2003-2015 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.
-//
-// **********************************************************************
-
-class Grammar
-{
- Grammar(Parser p)
- {
- _parser = p;
- _scanner = new Scanner(_parser);
- }
-
- void
- parse()
- {
- while(true)
- {
- try
- {
- _token = _scanner.nextToken();
- if(_token == null)
- {
- return;
- }
- else if(_token.type == Token.TOK_SEMI)
- {
- // Continue
- }
- else if(_token.type == Token.TOK_HELP)
- {
- _token = _scanner.nextToken();
- if(_token.type != Token.TOK_SEMI)
- {
- throw new ParseError("Expected ';'");
- }
- _parser.usage();
- }
- else if(_token.type == Token.TOK_EXIT)
- {
- _token = _scanner.nextToken();
- if(_token.type != Token.TOK_SEMI)
- {
- throw new ParseError("Expected ';'");
- }
- return;
- }
- else if(_token.type == Token.TOK_LIST)
- {
- _token = _scanner.nextToken();
- if(_token.type != Token.TOK_SEMI)
- {
- throw new ParseError("Expected ';'");
- }
- _parser.list(false);
- }
- else if(_token.type == Token.TOK_LIST_RECURSIVE)
- {
- _token = _scanner.nextToken();
- if(_token.type != Token.TOK_SEMI)
- {
- throw new ParseError("Expected ';'");
- }
- _parser.list(true);
- }
- else if(_token.type == Token.TOK_CREATE_FILE)
- {
- java.util.List<String> s = strings();
- if(_token.type != Token.TOK_SEMI)
- {
- throw new ParseError("Expected ';'");
- }
- if(s.size() == 0)
- {
- throw new ParseError("usage: mkfile FILE [FILE...]");
- }
- _parser.createFile(s);
- }
- else if(_token.type == Token.TOK_CREATE_DIR)
- {
- java.util.List<String> s = strings();
- if(_token.type != Token.TOK_SEMI)
- {
- throw new ParseError("Expected ';'");
- }
- if(s.size() == 0)
- {
- throw new ParseError("usage: mkdir DIR [DIR...]");
- }
- _parser.createDir(s);
- }
- else if(_token.type == Token.TOK_PWD)
- {
- _token = _scanner.nextToken();
- if(_token.type != Token.TOK_SEMI)
- {
- throw new ParseError("Expected ';'");
- }
- _parser.pwd();
- }
- else if(_token.type == Token.TOK_CD)
- {
- java.util.List<String> s = strings();
- if(_token.type != Token.TOK_SEMI)
- {
- throw new ParseError("Expected ';'");
- }
- if(s.size() > 1)
- {
- throw new ParseError("usage: cd [DIR]");
- }
- else if(s.size() == 0)
- {
- _parser.cd("/");
- }
- else
- {
- _parser.cd(s.get(0));
- }
- }
- else if(_token.type == Token.TOK_CAT)
- {
- java.util.List<String> s = strings();
- if(_token.type != Token.TOK_SEMI)
- {
- throw new ParseError("Expected ';'");
- }
- if(s.size() != 1)
- {
- throw new ParseError("usage: cat FILE");
- }
- _parser.cat(s.get(0));
- }
- else if(_token.type == Token.TOK_WRITE)
- {
- java.util.LinkedList<String> s = strings();
- if(_token.type != Token.TOK_SEMI)
- {
- throw new ParseError("Expected ';'");
- }
- if(s.size() == 0)
- {
- throw new ParseError("usage: write FILE [STRING...]");
- }
- _parser.write(s);
- }
- else if(_token.type == Token.TOK_RM)
- {
- java.util.List<String> s = strings();
- if(_token.type != Token.TOK_SEMI)
- {
- throw new ParseError("Expected ';'");
- }
- if(s.size() == 0)
- {
- throw new ParseError("usage: rm NAME [NAME...]");
- }
- _parser.destroy(s);
- }
- else
- {
- _parser.error("parse error");
- }
- }
- catch(ParseError e)
- {
- _parser.error("Parse error: " + e.getMessage());
- }
- }
- }
-
- private java.util.LinkedList<String>
- strings()
- {
- java.util.LinkedList<String> l = new java.util.LinkedList<String>();
- while(true)
- {
- _token = _scanner.nextToken();
- if(_token.type != Token.TOK_STRING)
- {
- return l;
- }
- l.add(_token.value);
- }
- }
-
- static private class ParseError extends RuntimeException
- {
- ParseError(String msg)
- {
- super(msg);
- }
- }
-
- private Parser _parser;
- private Scanner _scanner;
- private Token _token;
-}
diff --git a/java/demo/Manual/evictor_filesystem/NodeFactory.java b/java/demo/Manual/evictor_filesystem/NodeFactory.java
deleted file mode 100644
index 851af0d4a3b..00000000000
--- a/java/demo/Manual/evictor_filesystem/NodeFactory.java
+++ /dev/null
@@ -1,38 +0,0 @@
-// **********************************************************************
-//
-// Copyright (c) 2003-2015 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 Filesystem.*;
-
-public class NodeFactory implements Ice.ObjectFactory
-{
- @Override
- public Ice.Object
- create(String type)
- {
- if(type.equals(PersistentFile.ice_staticId()))
- {
- return new FileI();
- }
- else if(type.equals(PersistentDirectory.ice_staticId()))
- {
- return new DirectoryI();
- }
- else
- {
- assert(false);
- return null;
- }
- }
-
- @Override
- public void
- destroy()
- {
- }
-}
diff --git a/java/demo/Manual/evictor_filesystem/Parser.java b/java/demo/Manual/evictor_filesystem/Parser.java
deleted file mode 100644
index 5e7854156aa..00000000000
--- a/java/demo/Manual/evictor_filesystem/Parser.java
+++ /dev/null
@@ -1,349 +0,0 @@
-// **********************************************************************
-//
-// Copyright (c) 2003-2015 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 Filesystem.*;
-
-class Parser
-{
- Parser(DirectoryPrx root)
- {
- _dirs = new java.util.LinkedList<DirectoryPrx>();
- _dirs.addFirst(root);
- }
-
- void
- usage()
- {
- System.err.print(
- "help Print this message.\n" +
- "pwd Print current directory (/ = root).\n" +
- "cd [DIR] Change directory (/ or empty = root).\n" +
- "ls List current directory.\n" +
- "lr Recursively list current directory.\n" +
- "mkdir DIR [DIR...] Create directories DIR in current directory.\n" +
- "mkfile FILE [FILE...] Create files FILE in current directory.\n" +
- "rm NAME [NAME...] Delete directory or file NAME (rm * to delete all).\n" +
- "cat FILE List the contents of FILE.\n" +
- "write FILE [STRING...] Write STRING to FILE.\n" +
- "exit, quit Exit this program.\n");
- }
-
- void
- list(boolean recursive)
- {
- try
- {
- list(_dirs.get(0), recursive, 0);
- }
- catch(Ice.LocalException ex)
- {
- error(ex.toString());
- }
- }
-
- void
- list(Filesystem.DirectoryPrx dir, boolean recursive, int depth)
- {
- StringBuilder b = new StringBuilder();
- for(int i = 0; i < depth; ++i)
- {
- b.append('\t');
- }
- String indent = b.toString();
-
- NodeDesc[] contents = dir.list();
-
- for(int i = 0; i < contents.length; ++i)
- {
- DirectoryPrx d
- = contents[i].type == NodeType.DirType
- ? DirectoryPrxHelper.uncheckedCast(contents[i].proxy)
- : null;
- System.out.print(indent + contents[i].name + (d != null ? " (directory)" : " (file)"));
- if(d != null && recursive)
- {
- System.out.println(":");
- list(d, true, ++depth);
- }
- else
- {
- System.out.println();
- }
- }
- }
-
- void
- createFile(java.util.List<String> names)
- {
- DirectoryPrx dir = _dirs.getFirst();
-
- for(String name : names)
- {
- if(name.equals(".."))
- {
- System.out.println("Cannot create a file named `..'");
- continue;
- }
-
- try
- {
- dir.createFile(name);
- }
- catch(NameInUse ex)
- {
- System.out.println("`" + name + "' exists already");
- }
- }
- }
-
- void
- createDir(java.util.List<String> names)
- {
- DirectoryPrx dir = _dirs.getFirst();
-
- for(String name : names)
- {
- if(name.equals(".."))
- {
- System.out.println("Cannot create a directory named `..'");
- continue;
- }
-
- try
- {
- dir.createDirectory(name);
- }
- catch(NameInUse ex)
- {
- System.out.println("`" + name + "' exists already");
- }
- }
- }
-
- void
- pwd()
- {
- if(_dirs.size() == 1)
- {
- System.out.print("/");
- }
- else
- {
- java.util.ListIterator<DirectoryPrx> i = _dirs.listIterator(_dirs.size());
- i.previous();
- while(i.hasPrevious())
- {
- System.out.print("/" + i.previous().name());
- }
- }
- System.out.println();
- }
-
- void
- cd(String name)
- {
- if(name.equals("/"))
- {
- while(_dirs.size() > 1)
- {
- _dirs.removeFirst();
- }
- return;
- }
-
- if(name.equals(".."))
- {
- if(_dirs.size() > 1)
- {
- _dirs.removeFirst();
- }
- return;
- }
-
- DirectoryPrx dir = _dirs.getFirst();
- NodeDesc d;
- try
- {
- d = dir.find(name);
- }
- catch(NoSuchName ex)
- {
- System.out.println("`" + name + "': no such directory");
- return;
- }
- if(d.type == NodeType.FileType)
- {
- System.out.println("`" + name + "': not a directory");
- return;
- }
- _dirs.addFirst(DirectoryPrxHelper.uncheckedCast(d.proxy));
- }
-
- void
- cat(String name)
- {
- DirectoryPrx dir = _dirs.getFirst();
- NodeDesc d;
- try
- {
- d = dir.find(name);
- }
- catch(NoSuchName ex)
- {
- System.out.println("`" + name + "': no such file");
- return;
- }
- if(d.type == NodeType.DirType)
- {
- System.out.println("`" + name + "': not a file");
- return;
- }
- FilePrx f = FilePrxHelper.uncheckedCast(d.proxy);
- String[] l = f.read();
- for(int i = 0; i < l.length; ++i)
- {
- System.out.println(l[i]);
- }
- }
-
- void
- write(java.util.LinkedList<String> args)
- {
- DirectoryPrx dir = _dirs.getFirst();
- String name = args.getFirst();
- args.removeFirst();
- NodeDesc d;
- try
- {
- d = dir.find(name);
- }
- catch(NoSuchName ex)
- {
- System.out.println("`" + name + "': no such file");
- return;
- }
- if(d.type == NodeType.DirType)
- {
- System.out.println("`" + name + "': not a file");
- return;
- }
- FilePrx f = FilePrxHelper.uncheckedCast(d.proxy);
-
- String[] l = args.toArray(new String[0]);
- try
- {
- f.write(l);
- }
- catch(GenericError ex)
- {
- System.out.println("`" + name + "': cannot write to file: " + ex.reason);
- }
- }
-
- void
- destroy(java.util.List<String> names)
- {
- DirectoryPrx dir = _dirs.getFirst();
-
- for(String name : names)
- {
- if(name.equals("*"))
- {
- NodeDesc[] nodes = dir.list();
- for(NodeDesc node : nodes)
- {
- try
- {
- node.proxy.destroy();
- }
- catch(PermissionDenied ex)
- {
- System.out.println("cannot remove `" + node.name + "': " + ex.reason);
- }
- }
- return;
- }
- else
- {
- NodeDesc d;
- try
- {
- d = dir.find(name);
- }
- catch(NoSuchName ex)
- {
- System.out.println("`" + name + "': no such file or directory");
- return;
- }
- try
- {
- d.proxy.destroy();
- }
- catch(PermissionDenied ex)
- {
- System.out.println("cannot remove `" + name + "': " + ex.reason);
- }
- }
- }
- }
-
- void
- error(String s)
- {
- System.err.println("error: " + s);
- }
-
- void
- warning(String s)
- {
- System.err.println("warning: " + s);
- }
-
- String
- getInput()
- {
- System.out.print("> ");
- System.out.flush();
-
- try
- {
- return _in.readLine();
- }
- catch(java.io.IOException e)
- {
- return null;
- }
- }
-
- int
- parse()
- {
- _in = new java.io.BufferedReader(new java.io.InputStreamReader(System.in));
-
- Grammar g = new Grammar(this);
- g.parse();
-
- return 0;
- }
-
- int
- parse(java.io.BufferedReader in)
- {
- _in = in;
-
- Grammar g = new Grammar(this);
- g.parse();
-
- return 0;
- }
-
- private java.util.LinkedList<DirectoryPrx> _dirs;
-
- private java.io.BufferedReader _in;
-}
diff --git a/java/demo/Manual/evictor_filesystem/PersistentFilesystem.ice b/java/demo/Manual/evictor_filesystem/PersistentFilesystem.ice
deleted file mode 100644
index b1334994276..00000000000
--- a/java/demo/Manual/evictor_filesystem/PersistentFilesystem.ice
+++ /dev/null
@@ -1,38 +0,0 @@
-// **********************************************************************
-//
-// Copyright (c) 2003-2015 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.
-//
-// **********************************************************************
-
-#pragma once
-
-#include <Filesystem.ice>
-
-module Filesystem
-{
- class PersistentDirectory;
-
- class PersistentNode implements Node
- {
- string nodeName;
- PersistentDirectory* parent;
- };
-
- class PersistentFile extends PersistentNode implements File
- {
- Lines text;
- };
-
- dictionary<string, NodeDesc> NodeDict;
-
- class PersistentDirectory extends PersistentNode implements Directory
- {
- ["freeze:write"]
- void removeNode(string name);
-
- NodeDict nodes;
- };
-};
diff --git a/java/demo/Manual/evictor_filesystem/README b/java/demo/Manual/evictor_filesystem/README
deleted file mode 100644
index 73ff1f9f14d..00000000000
--- a/java/demo/Manual/evictor_filesystem/README
+++ /dev/null
@@ -1,11 +0,0 @@
-This demo presents an alternate implementation of the filesystem
-application using a Freeze evictor, as discussed in the Freeze chapter
-of the Ice manual.
-
-To run it, start the server in a window:
-
-$ java -jar build/libs/server.jar
-
-Then run the client in a separate window:
-
-$ java -jar build/libs/client.jar
diff --git a/java/demo/Manual/evictor_filesystem/Scanner.java b/java/demo/Manual/evictor_filesystem/Scanner.java
deleted file mode 100644
index 18ac8eacf09..00000000000
--- a/java/demo/Manual/evictor_filesystem/Scanner.java
+++ /dev/null
@@ -1,283 +0,0 @@
-// **********************************************************************
-//
-// Copyright (c) 2003-2015 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.
-//
-// **********************************************************************
-
-class Scanner
-{
- Scanner(Parser p)
- {
- _parser = p;
- }
-
- Token
- nextToken()
- {
- String s = next();
- if(s == null)
- {
- return null;
- }
-
- if(s.equals(";"))
- {
- return new Token(Token.TOK_SEMI);
- }
- else if(s.equals("help"))
- {
- return new Token(Token.TOK_HELP);
- }
- else if(s.equals("exit") || s.equals("quit"))
- {
- return new Token(Token.TOK_EXIT);
- }
- else if(s.equals("ls"))
- {
- return new Token(Token.TOK_LIST);
- }
- else if(s.equals("lr"))
- {
- return new Token(Token.TOK_LIST_RECURSIVE);
- }
- else if(s.equals("mkfile"))
- {
- return new Token(Token.TOK_CREATE_FILE);
- }
- else if(s.equals("mkdir"))
- {
- return new Token(Token.TOK_CREATE_DIR);
- }
- else if(s.equals("pwd"))
- {
- return new Token(Token.TOK_PWD);
- }
- else if(s.equals("cd"))
- {
- return new Token(Token.TOK_CD);
- }
- else if(s.equals("cat"))
- {
- return new Token(Token.TOK_CAT);
- }
- else if(s.equals("write"))
- {
- return new Token(Token.TOK_WRITE);
- }
- else if(s.equals("rm"))
- {
- return new Token(Token.TOK_RM);
- }
- else
- {
- return new Token(Token.TOK_STRING, s);
- }
- }
-
- static private class EndOfInput extends Exception
- {
- }
-
- private char
- get()
- throws EndOfInput
- {
- //
- // If there is an character in the unget buffer, return it.
- //
- if(_unget)
- {
- _unget = false;
- return _ungetChar;
- }
-
- //
- // No current buffer?
- //
- if(_buf == null)
- {
- _buf = _parser.getInput();
- _pos = 0;
- if(_buf == null)
- {
- throw new EndOfInput();
- }
- }
-
- //
- // At the end-of-buffer?
- //
- while(_pos >= _buf.length())
- {
- _buf = null;
- _pos = 0;
- return '\n';
- }
-
- return _buf.charAt(_pos++);
- }
-
- //
- // unget only works with one character.
- //
- private void
- unget(char c)
- {
- assert(!_unget);
- _unget = true;
- _ungetChar = c;
- }
-
- private String
- next()
- {
- //
- // Eat any whitespace.
- //
- char c;
- try
- {
- do
- {
- c = get();
- }
- while(Character.isWhitespace(c) && c != '\n');
- }
- catch(EndOfInput ignore)
- {
- return null;
- }
-
- StringBuilder buf = new StringBuilder(128);
-
- if(c == ';' || c == '\n')
- {
- buf.append(';');
- }
- else if(c == '\'')
- {
- try
- {
- while(true)
- {
- c = get();
- if(c == '\'')
- {
- break;
- }
- else
- {
- buf.append(c);
- }
- }
- }
- catch(EndOfInput e)
- {
- _parser.warning("EOF in string");
- }
- }
- else if(c == '\"')
- {
- try
- {
- while(true)
- {
- c = get();
- if(c == '\"')
- {
- break;
- }
- else if(c == '\\')
- {
- try
- {
- char next = get();
- switch(next)
- {
- case '\\':
- case '"':
- {
- buf.append(next);
- break;
- }
-
- case 'n':
- {
- buf.append('\n');
- break;
- }
-
- case 'r':
- {
- buf.append('\r');
- break;
- }
-
- case 't':
- {
- buf.append('\t');
- break;
- }
-
- case 'f':
- {
- buf.append('\f');
- break;
- }
-
- default:
- {
- buf.append(c);
- unget(next);
- }
- }
- }
- catch(EndOfInput e)
- {
- buf.append(c);
- }
- }
- else
- {
- buf.append(c);
- }
- }
- }
- catch(EndOfInput e)
- {
- _parser.warning("EOF in string");
- }
- }
- else
- {
- //
- // Otherwise it's a string.
- //
- try
- {
- do
- {
- buf.append(c);
- c = get();
- }
- while(!Character.isWhitespace(c) && c != ';' && c != '\n');
-
- unget(c);
- }
- catch(EndOfInput ignore)
- {
- }
- }
-
- return buf.toString();
- }
-
- private Parser _parser;
- private boolean _unget = false;
- private char _ungetChar;
- private String _buf = null;
- private int _pos;
-}
diff --git a/java/demo/Manual/evictor_filesystem/Server.java b/java/demo/Manual/evictor_filesystem/Server.java
deleted file mode 100644
index cc84dec9ffe..00000000000
--- a/java/demo/Manual/evictor_filesystem/Server.java
+++ /dev/null
@@ -1,82 +0,0 @@
-// **********************************************************************
-//
-// Copyright (c) 2003-2015 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 Filesystem.*;
-
-public class Server extends Ice.Application
-{
- public
- Server(String envName)
- {
- _envName = envName;
- }
-
- @Override
- public int
- run(String[] args)
- {
- //
- // Install object factories.
- //
- Ice.ObjectFactory factory = new NodeFactory();
- communicator().addObjectFactory(factory, PersistentFile.ice_staticId());
- communicator().addObjectFactory(factory, PersistentDirectory.ice_staticId());
-
- //
- // Create an object adapter.
- //
- Ice.ObjectAdapter adapter = communicator().createObjectAdapter("EvictorFilesystem");
-
- //
- // Create the Freeze evictor (stored in the _evictor
- // static member).
- //
- Freeze.Evictor evictor = Freeze.Util.createTransactionalEvictor(adapter, _envName, "evictorfs",
- null, null, null, true);
- DirectoryI._evictor = evictor;
- FileI._evictor = evictor;
-
- adapter.addServantLocator(evictor, "");
-
- //
- // Create the root node if it doesn't exist.
- //
- Ice.Identity rootId = new Ice.Identity();
- rootId.name = "RootDir";
- if(!evictor.hasObject(rootId))
- {
- PersistentDirectory root = new DirectoryI();
- root.nodeName = "/";
- root.nodes = new java.util.HashMap<java.lang.String, NodeDesc>();
- evictor.add(root, rootId);
- }
-
- //
- // Ready to accept requests now.
- //
- adapter.activate();
-
- //
- // Wait until we are done.
- //
- communicator().waitForShutdown();
-
- return 0;
- }
-
- public static void
- main(String[] args)
- {
- Server app = new Server("db");
- int status = app.main("demo.book.evictor_filesystem.Server", args, "config.server");
- System.exit(status);
- }
-
- private String _envName;
-}
diff --git a/java/demo/Manual/evictor_filesystem/Token.java b/java/demo/Manual/evictor_filesystem/Token.java
deleted file mode 100644
index bcbb7baf96e..00000000000
--- a/java/demo/Manual/evictor_filesystem/Token.java
+++ /dev/null
@@ -1,40 +0,0 @@
-// **********************************************************************
-//
-// Copyright (c) 2003-2015 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.
-//
-// **********************************************************************
-
-class Token
-{
- public static final int TOK_HELP = 0;
- public static final int TOK_EXIT = 1;
- public static final int TOK_SEMI = 2;
- public static final int TOK_LIST = 3;
- public static final int TOK_LIST_RECURSIVE = 4;
- public static final int TOK_CREATE_FILE = 5;
- public static final int TOK_CREATE_DIR = 6;
- public static final int TOK_PWD = 7;
- public static final int TOK_CD = 8;
- public static final int TOK_CAT = 9;
- public static final int TOK_WRITE = 10;
- public static final int TOK_RM = 11;
- public static final int TOK_STRING = 12;
-
- int type;
- String value;
-
- Token(int t)
- {
- type = t;
- value = null;
- }
-
- Token(int t, String v)
- {
- type = t;
- value = v;
- }
-}
diff --git a/java/demo/Manual/evictor_filesystem/config.client b/java/demo/Manual/evictor_filesystem/config.client
deleted file mode 100644
index 640cfade4f1..00000000000
--- a/java/demo/Manual/evictor_filesystem/config.client
+++ /dev/null
@@ -1,28 +0,0 @@
-#
-# The client reads this property to create the reference to the root
-# "directory" object in the server.
-#
-RootDir.Proxy=RootDir:default -h localhost -p 10000
-
-#
-# Warn about connection exceptions
-#
-Ice.Warn.Connections=1
-
-#
-# Network Tracing
-#
-# 0 = no network tracing
-# 1 = trace connection establishment and closure
-# 2 = like 1, but more detailed
-# 3 = like 2, but also trace data transfer
-#
-#Ice.Trace.Network=1
-
-#
-# Protocol Tracing
-#
-# 0 = no protocol tracing
-# 1 = trace protocol messages
-#
-#Ice.Trace.Protocol=1
diff --git a/java/demo/Manual/evictor_filesystem/config.server b/java/demo/Manual/evictor_filesystem/config.server
deleted file mode 100644
index 69e536ab202..00000000000
--- a/java/demo/Manual/evictor_filesystem/config.server
+++ /dev/null
@@ -1,49 +0,0 @@
-#
-# Configure the server endpoints.
-#
-EvictorFilesystem.Endpoints=default -h localhost -p 10000
-
-#
-# Freeze Map Tracing.
-#
-# 0 = No map activity trace (default).
-# 1 = Trace database open and close.
-# 2 = Also trace iterator and transaction operations, and reference
-# counting of the underlying database.
-#
-Freeze.Trace.Map=1
-
-#
-# Freeze Evictor Tracing.
-#
-# 0 = No evictor activity trace (default).
-# 1 = Trace Ice object and facet creation and destruction, facet
-# streaming time, facet saving time, object eviction (every 50
-# objects) and evictor deactivation.
-# 2 = Also trace object lookups, and all object evictions.
-# 3 = Also trace object retrieval from the database.
-#
-Freeze.Trace.Evictor=2
-
-#
-# Warn about connection exceptions
-#
-Ice.Warn.Connections=1
-
-#
-# Network Tracing
-#
-# 0 = no network tracing
-# 1 = trace connection establishment and closure
-# 2 = like 1, but more detailed
-# 3 = like 2, but also trace data transfer
-#
-#Ice.Trace.Network=1
-
-#
-# Protocol Tracing
-#
-# 0 = no protocol tracing
-# 1 = trace protocol messages
-#
-#Ice.Trace.Protocol=1
diff --git a/java/demo/Manual/evictor_filesystem/db/.gitignore b/java/demo/Manual/evictor_filesystem/db/.gitignore
deleted file mode 100644
index 39af5887579..00000000000
--- a/java/demo/Manual/evictor_filesystem/db/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-# Dummy file, so that git retains this otherwise empty directory.
diff --git a/java/demo/Manual/evictor_filesystem/expect.py b/java/demo/Manual/evictor_filesystem/expect.py
deleted file mode 100755
index 0c682a99f07..00000000000
--- a/java/demo/Manual/evictor_filesystem/expect.py
+++ /dev/null
@@ -1,34 +0,0 @@
-#!/usr/bin/env python
-# **********************************************************************
-#
-# Copyright (c) 2003-2015 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 sys, os
-
-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, "demoscript")) ]
-if len(path) == 0:
- raise RuntimeError("can't find toplevel directory!")
-sys.path.append(path[0])
-
-from demoscript import Util
-from demoscript.manual import evictor_filesystem
-
-sys.stdout.write("cleaning databases... ")
-sys.stdout.flush()
-Util.cleanDbDir("db")
-print("ok")
-
-server = Util.spawn('java -jar build/libs/server.jar --Ice.PrintAdapterReady')
-server.expect('.* ready')
-client = Util.spawn('java -jar build/libs/client.jar')
-
-evictor_filesystem.run(client, server)