repo
stringlengths
7
58
path
stringlengths
12
218
func_name
stringlengths
3
140
original_string
stringlengths
73
34.1k
language
stringclasses
1 value
code
stringlengths
73
34.1k
code_tokens
list
docstring
stringlengths
3
16k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
105
339
partition
stringclasses
1 value
threerings/narya
core/src/main/java/com/threerings/presents/server/PresentsServer.java
PresentsServer.runServer
public static void runServer (Module... modules) { Injector injector = Guice.createInjector(modules); PresentsServer server = injector.getInstance(PresentsServer.class); try { // initialize the server server.init(injector); // check to see if we should load and invoke a test module before running the server String testmod = System.getProperty("test_module"); if (testmod != null) { try { log.info("Invoking test module", "mod", testmod); Class<?> tmclass = Class.forName(testmod); Runnable trun = (Runnable)tmclass.newInstance(); trun.run(); } catch (Exception e) { log.warning("Unable to invoke test module '" + testmod + "'.", e); } } // start the server to running (this method call won't return until the server is shut // down) server.run(); } catch (Throwable t) { log.warning("Unable to initialize server.", t); System.exit(-1); } }
java
public static void runServer (Module... modules) { Injector injector = Guice.createInjector(modules); PresentsServer server = injector.getInstance(PresentsServer.class); try { // initialize the server server.init(injector); // check to see if we should load and invoke a test module before running the server String testmod = System.getProperty("test_module"); if (testmod != null) { try { log.info("Invoking test module", "mod", testmod); Class<?> tmclass = Class.forName(testmod); Runnable trun = (Runnable)tmclass.newInstance(); trun.run(); } catch (Exception e) { log.warning("Unable to invoke test module '" + testmod + "'.", e); } } // start the server to running (this method call won't return until the server is shut // down) server.run(); } catch (Throwable t) { log.warning("Unable to initialize server.", t); System.exit(-1); } }
[ "public", "static", "void", "runServer", "(", "Module", "...", "modules", ")", "{", "Injector", "injector", "=", "Guice", ".", "createInjector", "(", "modules", ")", ";", "PresentsServer", "server", "=", "injector", ".", "getInstance", "(", "PresentsServer", "...
Inits and runs the PresentsServer bound in the given modules. This blocks until the server is shut down.
[ "Inits", "and", "runs", "the", "PresentsServer", "bound", "in", "the", "given", "modules", ".", "This", "blocks", "until", "the", "server", "is", "shut", "down", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/server/PresentsServer.java#L118-L147
train
threerings/narya
core/src/main/java/com/threerings/presents/server/PresentsServer.java
PresentsServer.run
public void run () { // wait till everything in the dobjmgr queue and invokers are processed and then start the // connection manager ((PresentsInvoker)_invoker).postRunnableWhenEmpty(new Runnable() { public void run () { // Take as long as you like opening to the public _omgr.postRunnable(new LongRunnable() { public void run () { openToThePublic(); } }); } }); // invoke the dobjmgr event loop _omgr.run(); }
java
public void run () { // wait till everything in the dobjmgr queue and invokers are processed and then start the // connection manager ((PresentsInvoker)_invoker).postRunnableWhenEmpty(new Runnable() { public void run () { // Take as long as you like opening to the public _omgr.postRunnable(new LongRunnable() { public void run () { openToThePublic(); } }); } }); // invoke the dobjmgr event loop _omgr.run(); }
[ "public", "void", "run", "(", ")", "{", "// wait till everything in the dobjmgr queue and invokers are processed and then start the", "// connection manager", "(", "(", "PresentsInvoker", ")", "_invoker", ")", ".", "postRunnableWhenEmpty", "(", "new", "Runnable", "(", ")", ...
Starts up all of the server services and enters the main server event loop.
[ "Starts", "up", "all", "of", "the", "server", "services", "and", "enters", "the", "main", "server", "event", "loop", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/server/PresentsServer.java#L229-L245
train
threerings/narya
core/src/main/java/com/threerings/presents/server/PresentsServer.java
PresentsServer.openToThePublic
protected void openToThePublic () { if (getListenPorts().length != 0 && !_socketAcceptor.bind()) { queueShutdown(); } else { _datagramReader.bind(); _conmgr.start(); } }
java
protected void openToThePublic () { if (getListenPorts().length != 0 && !_socketAcceptor.bind()) { queueShutdown(); } else { _datagramReader.bind(); _conmgr.start(); } }
[ "protected", "void", "openToThePublic", "(", ")", "{", "if", "(", "getListenPorts", "(", ")", ".", "length", "!=", "0", "&&", "!", "_socketAcceptor", ".", "bind", "(", ")", ")", "{", "queueShutdown", "(", ")", ";", "}", "else", "{", "_datagramReader", ...
Opens the server for connections after the event thread is running and all the invokers are clear after starting up.
[ "Opens", "the", "server", "for", "connections", "after", "the", "event", "thread", "is", "running", "and", "all", "the", "invokers", "are", "clear", "after", "starting", "up", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/server/PresentsServer.java#L251-L259
train
threerings/narya
tools/src/main/java/com/threerings/presents/tools/SourceFile.java
SourceFile.readFrom
public void readFrom (File source) throws IOException { // slurp our source file into newline separated strings _lines = Lists.newArrayList(); BufferedReader bin = new BufferedReader(new FileReader(source)); String line = null; while ((line = bin.readLine()) != null) { _lines.add(line); } bin.close(); // now determine where to insert our static field declarations and our generated methods int bstart = -1, bend = -1; for (int ii = 0, nn = _lines.size(); ii < nn; ii++) { line = _lines.get(ii).trim(); // look for the start of the class body if (GenUtil.NAME_PATTERN.matcher(line).find()) { if (line.endsWith("{")) { bstart = ii+1; } else { // search down a few lines for the open brace for (int oo = 1; oo < 10; oo++) { if (safeGetLine(ii+oo).trim().endsWith("{")) { bstart = ii+oo+1; break; } } } // track the last } on a line by itself and we'll call that the end of the class body } else if (line.equals("}")) { bend = ii; // look for our field and method markers } else if (line.equals(FIELDS_START)) { _nstart = ii; } else if (line.equals(FIELDS_END)) { _nend = ii+1; } else if (line.equals(METHODS_START)) { _mstart = ii; } else if (line.equals(METHODS_END)) { _mend = ii+1; } } // sanity check the markers check(source, "fields start", _nstart, "fields end", _nend); check(source, "fields end", _nend, "fields start", _nstart); check(source, "methods start", _mstart, "methods end", _mend); check(source, "methods end", _mend, "methods start", _mstart); // we have no previous markers then stuff the fields at the top of the class body and the // methods at the bottom if (_nstart == -1) { _nstart = bstart; _nend = bstart; } if (_mstart == -1) { _mstart = bend; _mend = bend; } }
java
public void readFrom (File source) throws IOException { // slurp our source file into newline separated strings _lines = Lists.newArrayList(); BufferedReader bin = new BufferedReader(new FileReader(source)); String line = null; while ((line = bin.readLine()) != null) { _lines.add(line); } bin.close(); // now determine where to insert our static field declarations and our generated methods int bstart = -1, bend = -1; for (int ii = 0, nn = _lines.size(); ii < nn; ii++) { line = _lines.get(ii).trim(); // look for the start of the class body if (GenUtil.NAME_PATTERN.matcher(line).find()) { if (line.endsWith("{")) { bstart = ii+1; } else { // search down a few lines for the open brace for (int oo = 1; oo < 10; oo++) { if (safeGetLine(ii+oo).trim().endsWith("{")) { bstart = ii+oo+1; break; } } } // track the last } on a line by itself and we'll call that the end of the class body } else if (line.equals("}")) { bend = ii; // look for our field and method markers } else if (line.equals(FIELDS_START)) { _nstart = ii; } else if (line.equals(FIELDS_END)) { _nend = ii+1; } else if (line.equals(METHODS_START)) { _mstart = ii; } else if (line.equals(METHODS_END)) { _mend = ii+1; } } // sanity check the markers check(source, "fields start", _nstart, "fields end", _nend); check(source, "fields end", _nend, "fields start", _nstart); check(source, "methods start", _mstart, "methods end", _mend); check(source, "methods end", _mend, "methods start", _mstart); // we have no previous markers then stuff the fields at the top of the class body and the // methods at the bottom if (_nstart == -1) { _nstart = bstart; _nend = bstart; } if (_mstart == -1) { _mstart = bend; _mend = bend; } }
[ "public", "void", "readFrom", "(", "File", "source", ")", "throws", "IOException", "{", "// slurp our source file into newline separated strings", "_lines", "=", "Lists", ".", "newArrayList", "(", ")", ";", "BufferedReader", "bin", "=", "new", "BufferedReader", "(", ...
Reads the code from the supplied source file.
[ "Reads", "the", "code", "from", "the", "supplied", "source", "file", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/tools/src/main/java/com/threerings/presents/tools/SourceFile.java#L46-L109
train
threerings/narya
tools/src/main/java/com/threerings/presents/tools/SourceFile.java
SourceFile.containsString
public boolean containsString (String text) { for (int ii = 0, nn = _lines.size(); ii < nn; ii++) { // don't look inside the autogenerated areas if (!(ii >= _nstart && ii < _nend) && !(ii >= _mstart && ii < _mend) && _lines.get(ii).contains(text)) { return true; } } return false; }
java
public boolean containsString (String text) { for (int ii = 0, nn = _lines.size(); ii < nn; ii++) { // don't look inside the autogenerated areas if (!(ii >= _nstart && ii < _nend) && !(ii >= _mstart && ii < _mend) && _lines.get(ii).contains(text)) { return true; } } return false; }
[ "public", "boolean", "containsString", "(", "String", "text", ")", "{", "for", "(", "int", "ii", "=", "0", ",", "nn", "=", "_lines", ".", "size", "(", ")", ";", "ii", "<", "nn", ";", "ii", "++", ")", "{", "// don't look inside the autogenerated areas", ...
Returns true if the supplied text appears in the non-auto-generated section.
[ "Returns", "true", "if", "the", "supplied", "text", "appears", "in", "the", "non", "-", "auto", "-", "generated", "section", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/tools/src/main/java/com/threerings/presents/tools/SourceFile.java#L114-L124
train
threerings/narya
tools/src/main/java/com/threerings/presents/tools/SourceFile.java
SourceFile.generate
public String generate (String fsection, String msection) throws IOException { StringWriter writer = new StringWriter(); BufferedWriter bout = new BufferedWriter(writer); addOrRemoveGeneratedImport(StringUtil.deNull(fsection).contains("@Generated(") || StringUtil.deNull(msection).contains("@Generated(")); // write the preamble for (int ii = 0; ii < _nstart; ii++) { writeln(bout, _lines.get(ii)); } // write the field section if (!StringUtil.isBlank(fsection)) { String prev = safeGetLine(_nstart-1); if (!StringUtil.isBlank(prev) && !prev.equals("{")) { bout.newLine(); } writeln(bout, " " + FIELDS_START); bout.write(fsection); writeln(bout, " " + FIELDS_END); if (!StringUtil.isBlank(safeGetLine(_nend))) { bout.newLine(); } } // write the mid-amble for (int ii = _nend; ii < _mstart; ii++) { writeln(bout, _lines.get(ii)); } // write the method section if (!StringUtil.isBlank(msection)) { if (!StringUtil.isBlank(safeGetLine(_mstart-1))) { bout.newLine(); } writeln(bout, " " + METHODS_START); bout.write(msection); writeln(bout, " " + METHODS_END); String next = safeGetLine(_mend); if (!StringUtil.isBlank(next) && !next.equals("}")) { bout.newLine(); } } // write the postamble for (int ii = _mend, nn = _lines.size(); ii < nn; ii++) { writeln(bout, _lines.get(ii)); } bout.close(); return writer.toString(); }
java
public String generate (String fsection, String msection) throws IOException { StringWriter writer = new StringWriter(); BufferedWriter bout = new BufferedWriter(writer); addOrRemoveGeneratedImport(StringUtil.deNull(fsection).contains("@Generated(") || StringUtil.deNull(msection).contains("@Generated(")); // write the preamble for (int ii = 0; ii < _nstart; ii++) { writeln(bout, _lines.get(ii)); } // write the field section if (!StringUtil.isBlank(fsection)) { String prev = safeGetLine(_nstart-1); if (!StringUtil.isBlank(prev) && !prev.equals("{")) { bout.newLine(); } writeln(bout, " " + FIELDS_START); bout.write(fsection); writeln(bout, " " + FIELDS_END); if (!StringUtil.isBlank(safeGetLine(_nend))) { bout.newLine(); } } // write the mid-amble for (int ii = _nend; ii < _mstart; ii++) { writeln(bout, _lines.get(ii)); } // write the method section if (!StringUtil.isBlank(msection)) { if (!StringUtil.isBlank(safeGetLine(_mstart-1))) { bout.newLine(); } writeln(bout, " " + METHODS_START); bout.write(msection); writeln(bout, " " + METHODS_END); String next = safeGetLine(_mend); if (!StringUtil.isBlank(next) && !next.equals("}")) { bout.newLine(); } } // write the postamble for (int ii = _mend, nn = _lines.size(); ii < nn; ii++) { writeln(bout, _lines.get(ii)); } bout.close(); return writer.toString(); }
[ "public", "String", "generate", "(", "String", "fsection", ",", "String", "msection", ")", "throws", "IOException", "{", "StringWriter", "writer", "=", "new", "StringWriter", "(", ")", ";", "BufferedWriter", "bout", "=", "new", "BufferedWriter", "(", "writer", ...
Writes the code out to the specified file. @param fsection the new "generated fields" to write to the file, or null. @param msection the new "generated methods" to write to the file, or null.
[ "Writes", "the", "code", "out", "to", "the", "specified", "file", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/tools/src/main/java/com/threerings/presents/tools/SourceFile.java#L132-L184
train
threerings/narya
tools/src/main/java/com/threerings/presents/tools/SourceFile.java
SourceFile.check
protected void check (File source, String mname, int mline, String fname, int fline) throws IOException { if (mline == -1 && fline != -1) { throw new IOException( "Found " + fname + " marker (at line " + (fline+1) + ") but no " + mname + " marker in '" + source + "'."); } }
java
protected void check (File source, String mname, int mline, String fname, int fline) throws IOException { if (mline == -1 && fline != -1) { throw new IOException( "Found " + fname + " marker (at line " + (fline+1) + ") but no " + mname + " marker in '" + source + "'."); } }
[ "protected", "void", "check", "(", "File", "source", ",", "String", "mname", ",", "int", "mline", ",", "String", "fname", ",", "int", "fline", ")", "throws", "IOException", "{", "if", "(", "mline", "==", "-", "1", "&&", "fline", "!=", "-", "1", ")", ...
Helper function for sanity checking marker existence.
[ "Helper", "function", "for", "sanity", "checking", "marker", "existence", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/tools/src/main/java/com/threerings/presents/tools/SourceFile.java#L187-L195
train
threerings/narya
tools/src/main/java/com/threerings/presents/tools/SourceFile.java
SourceFile.writeln
protected void writeln (BufferedWriter bout, String line) throws IOException { bout.write(line); bout.newLine(); }
java
protected void writeln (BufferedWriter bout, String line) throws IOException { bout.write(line); bout.newLine(); }
[ "protected", "void", "writeln", "(", "BufferedWriter", "bout", ",", "String", "line", ")", "throws", "IOException", "{", "bout", ".", "write", "(", "line", ")", ";", "bout", ".", "newLine", "(", ")", ";", "}" ]
Helper function for writing a string and a newline to a writer.
[ "Helper", "function", "for", "writing", "a", "string", "and", "a", "newline", "to", "a", "writer", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/tools/src/main/java/com/threerings/presents/tools/SourceFile.java#L205-L210
train
threerings/narya
tools/src/main/java/com/threerings/presents/tools/SourceFile.java
SourceFile.addOrRemoveGeneratedImport
protected void addOrRemoveGeneratedImport (boolean add) { final String IMPORT = "import javax.annotation.Generated;"; int packageLine = -1; int importLine = -1; int lastJavaImport = -1; int firstNonJavaImport = -1; for (int ii = 0, nn = _lines.size(); ii < nn; ii++) { String line = _lines.get(ii); if (line.startsWith(IMPORT)) { if (add) { return; // we already got one! } importLine = ii; break; } else if (line.startsWith("package ")) { packageLine = ii; } else if (line.startsWith("import java")) { lastJavaImport = ii; } else if (firstNonJavaImport == -1 && line.startsWith("import ")) { firstNonJavaImport = ii; } } if (importLine != -1) { // we must be removing, or we'd have already exited _lines.remove(importLine); } else if (!add) { return; // it's already not there! } else { importLine = (lastJavaImport != -1) ? lastJavaImport + 1 : ((firstNonJavaImport != -1) ? firstNonJavaImport : packageLine + 1); _lines.add(importLine, IMPORT); } // the import line is always above these other lines, so they can be adjusted wholesale int adjustment = add ? 1 : -1; _nstart += adjustment; _nend += adjustment; _mstart += adjustment; _mend += adjustment; }
java
protected void addOrRemoveGeneratedImport (boolean add) { final String IMPORT = "import javax.annotation.Generated;"; int packageLine = -1; int importLine = -1; int lastJavaImport = -1; int firstNonJavaImport = -1; for (int ii = 0, nn = _lines.size(); ii < nn; ii++) { String line = _lines.get(ii); if (line.startsWith(IMPORT)) { if (add) { return; // we already got one! } importLine = ii; break; } else if (line.startsWith("package ")) { packageLine = ii; } else if (line.startsWith("import java")) { lastJavaImport = ii; } else if (firstNonJavaImport == -1 && line.startsWith("import ")) { firstNonJavaImport = ii; } } if (importLine != -1) { // we must be removing, or we'd have already exited _lines.remove(importLine); } else if (!add) { return; // it's already not there! } else { importLine = (lastJavaImport != -1) ? lastJavaImport + 1 : ((firstNonJavaImport != -1) ? firstNonJavaImport : packageLine + 1); _lines.add(importLine, IMPORT); } // the import line is always above these other lines, so they can be adjusted wholesale int adjustment = add ? 1 : -1; _nstart += adjustment; _nend += adjustment; _mstart += adjustment; _mend += adjustment; }
[ "protected", "void", "addOrRemoveGeneratedImport", "(", "boolean", "add", ")", "{", "final", "String", "IMPORT", "=", "\"import javax.annotation.Generated;\"", ";", "int", "packageLine", "=", "-", "1", ";", "int", "importLine", "=", "-", "1", ";", "int", "lastJa...
Add or remove an import for "@Generated", if needed.
[ "Add", "or", "remove", "an", "import", "for" ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/tools/src/main/java/com/threerings/presents/tools/SourceFile.java#L215-L262
train
threerings/narya
core/src/main/java/com/threerings/admin/client/FieldEditor.java
FieldEditor.updateBorder
protected void updateBorder (boolean modified) { if (modified) { setBorder(BorderFactory.createMatteBorder(2, 2, 2, 2, Color.red)); } else { setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); } }
java
protected void updateBorder (boolean modified) { if (modified) { setBorder(BorderFactory.createMatteBorder(2, 2, 2, 2, Color.red)); } else { setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); } }
[ "protected", "void", "updateBorder", "(", "boolean", "modified", ")", "{", "if", "(", "modified", ")", "{", "setBorder", "(", "BorderFactory", ".", "createMatteBorder", "(", "2", ",", "2", ",", "2", ",", "2", ",", "Color", ".", "red", ")", ")", ";", ...
Sets the appropriate border on this field editor based on whether or not the field is modified.
[ "Sets", "the", "appropriate", "border", "on", "this", "field", "editor", "based", "on", "whether", "or", "not", "the", "field", "is", "modified", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/admin/client/FieldEditor.java#L185-L192
train
threerings/narya
core/src/main/java/com/threerings/presents/dobj/DObject.java
DObject.addListener
public void addListener (ChangeListener listener, boolean weak) { // only add the listener if they're not already there int idx = getListenerIndex(listener); if (idx == -1) { _listeners = ListUtil.add(_listeners, weak ? new WeakReference<Object>(listener) : listener); return; } boolean oweak = _listeners[idx] instanceof WeakReference<?>; if (weak == oweak) { log.warning("Refusing repeat listener registration", "dobj", which(), "list", listener, new Exception()); } else { log.warning("Updating listener registered under different strength.", "dobj", which(), "list", listener, "oweak", oweak, "nweak", weak, new Exception()); _listeners[idx] = weak ? new WeakReference<Object>(listener) : listener; } }
java
public void addListener (ChangeListener listener, boolean weak) { // only add the listener if they're not already there int idx = getListenerIndex(listener); if (idx == -1) { _listeners = ListUtil.add(_listeners, weak ? new WeakReference<Object>(listener) : listener); return; } boolean oweak = _listeners[idx] instanceof WeakReference<?>; if (weak == oweak) { log.warning("Refusing repeat listener registration", "dobj", which(), "list", listener, new Exception()); } else { log.warning("Updating listener registered under different strength.", "dobj", which(), "list", listener, "oweak", oweak, "nweak", weak, new Exception()); _listeners[idx] = weak ? new WeakReference<Object>(listener) : listener; } }
[ "public", "void", "addListener", "(", "ChangeListener", "listener", ",", "boolean", "weak", ")", "{", "// only add the listener if they're not already there", "int", "idx", "=", "getListenerIndex", "(", "listener", ")", ";", "if", "(", "idx", "==", "-", "1", ")", ...
Adds an event listener to this object. The listener will be notified when any events are dispatched on this object that match their particular listener interface. <p> Note that the entity adding itself as a listener should have obtained the object reference by subscribing to it or should be acting on behalf of some other entity that subscribed to the object, <em>and</em> that it must be sure to remove itself from the listener list (via {@link #removeListener}) when it is done because unsubscribing from the object (done by whatever entity subscribed in the first place) is not guaranteed to result in the listeners added through that subscription being automatically removed (in most cases, they definitely will not be removed). @param listener the listener to be added. @param weak if true, retain only a weak reference to the listener (do not prevent the listener from being garbage-collected). @see EventListener @see AttributeChangeListener @see SetListener @see OidListListener
[ "Adds", "an", "event", "listener", "to", "this", "object", ".", "The", "listener", "will", "be", "notified", "when", "any", "events", "are", "dispatched", "on", "this", "object", "that", "match", "their", "particular", "listener", "interface", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/dobj/DObject.java#L201-L219
train
threerings/narya
core/src/main/java/com/threerings/presents/dobj/DObject.java
DObject.removeListener
public void removeListener (ChangeListener listener) { int idx = getListenerIndex(listener); if (idx != -1) { _listeners[idx] = null; } }
java
public void removeListener (ChangeListener listener) { int idx = getListenerIndex(listener); if (idx != -1) { _listeners[idx] = null; } }
[ "public", "void", "removeListener", "(", "ChangeListener", "listener", ")", "{", "int", "idx", "=", "getListenerIndex", "(", "listener", ")", ";", "if", "(", "idx", "!=", "-", "1", ")", "{", "_listeners", "[", "idx", "]", "=", "null", ";", "}", "}" ]
Removes an event listener from this object. The listener will no longer be notified when events are dispatched on this object. @param listener the listener to be removed.
[ "Removes", "an", "event", "listener", "from", "this", "object", ".", "The", "listener", "will", "no", "longer", "be", "notified", "when", "events", "are", "dispatched", "on", "this", "object", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/dobj/DObject.java#L227-L233
train
threerings/narya
core/src/main/java/com/threerings/presents/dobj/DObject.java
DObject.getSet
public final <T extends DSet.Entry> DSet<T> getSet (String setName) { @SuppressWarnings("unchecked") DSet<T> casted = (DSet<T>)getAccessor(setName).get(this); return casted; }
java
public final <T extends DSet.Entry> DSet<T> getSet (String setName) { @SuppressWarnings("unchecked") DSet<T> casted = (DSet<T>)getAccessor(setName).get(this); return casted; }
[ "public", "final", "<", "T", "extends", "DSet", ".", "Entry", ">", "DSet", "<", "T", ">", "getSet", "(", "String", "setName", ")", "{", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "DSet", "<", "T", ">", "casted", "=", "(", "DSet", "<", "T", ...
Get the DSet with the specified name.
[ "Get", "the", "DSet", "with", "the", "specified", "name", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/dobj/DObject.java#L258-L262
train
threerings/narya
core/src/main/java/com/threerings/presents/dobj/DObject.java
DObject.addToSet
public <T extends DSet.Entry> void addToSet (String setName, T entry) { requestEntryAdd(setName, getSet(setName), entry); }
java
public <T extends DSet.Entry> void addToSet (String setName, T entry) { requestEntryAdd(setName, getSet(setName), entry); }
[ "public", "<", "T", "extends", "DSet", ".", "Entry", ">", "void", "addToSet", "(", "String", "setName", ",", "T", "entry", ")", "{", "requestEntryAdd", "(", "setName", ",", "getSet", "(", "setName", ")", ",", "entry", ")", ";", "}" ]
Request to have the specified item added to the specified DSet.
[ "Request", "to", "have", "the", "specified", "item", "added", "to", "the", "specified", "DSet", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/dobj/DObject.java#L267-L270
train
threerings/narya
core/src/main/java/com/threerings/presents/dobj/DObject.java
DObject.updateSet
public void updateSet (String setName, DSet.Entry entry) { requestEntryUpdate(setName, getSet(setName), entry); }
java
public void updateSet (String setName, DSet.Entry entry) { requestEntryUpdate(setName, getSet(setName), entry); }
[ "public", "void", "updateSet", "(", "String", "setName", ",", "DSet", ".", "Entry", "entry", ")", "{", "requestEntryUpdate", "(", "setName", ",", "getSet", "(", "setName", ")", ",", "entry", ")", ";", "}" ]
Request to have the specified item updated in the specified DSet.
[ "Request", "to", "have", "the", "specified", "item", "updated", "in", "the", "specified", "DSet", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/dobj/DObject.java#L275-L278
train
threerings/narya
core/src/main/java/com/threerings/presents/dobj/DObject.java
DObject.removeFromSet
public void removeFromSet (String setName, Comparable<?> key) { requestEntryRemove(setName, getSet(setName), key); }
java
public void removeFromSet (String setName, Comparable<?> key) { requestEntryRemove(setName, getSet(setName), key); }
[ "public", "void", "removeFromSet", "(", "String", "setName", ",", "Comparable", "<", "?", ">", "key", ")", "{", "requestEntryRemove", "(", "setName", ",", "getSet", "(", "setName", ")", ",", "key", ")", ";", "}" ]
Request to have the specified key removed from the specified DSet.
[ "Request", "to", "have", "the", "specified", "key", "removed", "from", "the", "specified", "DSet", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/dobj/DObject.java#L283-L286
train
threerings/narya
core/src/main/java/com/threerings/presents/dobj/DObject.java
DObject.notifyListeners
public void notifyListeners (DEvent event) { if (_listeners == null) { return; } for (int ii = 0, ll = _listeners.length; ii < ll; ii++) { Object listener = _listeners[ii]; if (listener == null) { continue; } if (listener instanceof WeakReference<?>) { if ((listener = ((WeakReference<?>)listener).get()) == null) { _listeners[ii] = null; continue; } } try { // do any event specific notifications event.notifyListener(listener); // and notify them if they are listening for all events if (listener instanceof EventListener) { ((EventListener)listener).eventReceived(event); } } catch (Exception e) { log.warning("Listener choked during notification", "list", listener, "event", event, e); } } }
java
public void notifyListeners (DEvent event) { if (_listeners == null) { return; } for (int ii = 0, ll = _listeners.length; ii < ll; ii++) { Object listener = _listeners[ii]; if (listener == null) { continue; } if (listener instanceof WeakReference<?>) { if ((listener = ((WeakReference<?>)listener).get()) == null) { _listeners[ii] = null; continue; } } try { // do any event specific notifications event.notifyListener(listener); // and notify them if they are listening for all events if (listener instanceof EventListener) { ((EventListener)listener).eventReceived(event); } } catch (Exception e) { log.warning("Listener choked during notification", "list", listener, "event", event, e); } } }
[ "public", "void", "notifyListeners", "(", "DEvent", "event", ")", "{", "if", "(", "_listeners", "==", "null", ")", "{", "return", ";", "}", "for", "(", "int", "ii", "=", "0", ",", "ll", "=", "_listeners", ".", "length", ";", "ii", "<", "ll", ";", ...
Called by the distributed object manager after it has applied an event to this object. This dispatches an event notification to all of the listeners registered with this object. @param event the event that was just applied.
[ "Called", "by", "the", "distributed", "object", "manager", "after", "it", "has", "applied", "an", "event", "to", "this", "object", ".", "This", "dispatches", "an", "event", "notification", "to", "all", "of", "the", "listeners", "registered", "with", "this", ...
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/dobj/DObject.java#L408-L440
train
threerings/narya
core/src/main/java/com/threerings/presents/dobj/DObject.java
DObject.notifyProxies
public void notifyProxies (DEvent event) { if (_subs == null || event.isPrivate()) { return; } for (Object sub : _subs) { try { if (sub != null && sub instanceof ProxySubscriber) { ((ProxySubscriber)sub).eventReceived(event); } } catch (Exception e) { log.warning("Proxy choked during notification", "sub", sub, "event", event, e); } } }
java
public void notifyProxies (DEvent event) { if (_subs == null || event.isPrivate()) { return; } for (Object sub : _subs) { try { if (sub != null && sub instanceof ProxySubscriber) { ((ProxySubscriber)sub).eventReceived(event); } } catch (Exception e) { log.warning("Proxy choked during notification", "sub", sub, "event", event, e); } } }
[ "public", "void", "notifyProxies", "(", "DEvent", "event", ")", "{", "if", "(", "_subs", "==", "null", "||", "event", ".", "isPrivate", "(", ")", ")", "{", "return", ";", "}", "for", "(", "Object", "sub", ":", "_subs", ")", "{", "try", "{", "if", ...
Called by the distributed object manager after it has applied an event to this object. This dispatches an event notification to all of the proxy listeners registered with this object. @param event the event that was just applied.
[ "Called", "by", "the", "distributed", "object", "manager", "after", "it", "has", "applied", "an", "event", "to", "this", "object", ".", "This", "dispatches", "an", "event", "notification", "to", "all", "of", "the", "proxy", "listeners", "registered", "with", ...
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/dobj/DObject.java#L448-L463
train
threerings/narya
core/src/main/java/com/threerings/presents/dobj/DObject.java
DObject.changeAttribute
public void changeAttribute (String name, Object value) { Accessor acc = getAccessor(name); requestAttributeChange(name, value, acc.get(this)); acc.set(this, value); }
java
public void changeAttribute (String name, Object value) { Accessor acc = getAccessor(name); requestAttributeChange(name, value, acc.get(this)); acc.set(this, value); }
[ "public", "void", "changeAttribute", "(", "String", "name", ",", "Object", "value", ")", "{", "Accessor", "acc", "=", "getAccessor", "(", "name", ")", ";", "requestAttributeChange", "(", "name", ",", "value", ",", "acc", ".", "get", "(", "this", ")", ")"...
Requests that the specified attribute be changed to the specified value. Normally the generated setter methods should be used but in rare cases a caller may wish to update distributed fields in a generic manner.
[ "Requests", "that", "the", "specified", "attribute", "be", "changed", "to", "the", "specified", "value", ".", "Normally", "the", "generated", "setter", "methods", "should", "be", "used", "but", "in", "rare", "cases", "a", "caller", "may", "wish", "to", "upda...
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/dobj/DObject.java#L470-L475
train
threerings/narya
core/src/main/java/com/threerings/presents/dobj/DObject.java
DObject.postEvent
public void postEvent (DEvent event) { if (_tevent != null) { _tevent.postEvent(event); } else if (_omgr != null) { _omgr.postEvent(event); } else { log.info("Dropping event for non- or no longer managed object", "oid", getOid(), "class", getClass().getName(), "event", event); } }
java
public void postEvent (DEvent event) { if (_tevent != null) { _tevent.postEvent(event); } else if (_omgr != null) { _omgr.postEvent(event); } else { log.info("Dropping event for non- or no longer managed object", "oid", getOid(), "class", getClass().getName(), "event", event); } }
[ "public", "void", "postEvent", "(", "DEvent", "event", ")", "{", "if", "(", "_tevent", "!=", "null", ")", "{", "_tevent", ".", "postEvent", "(", "event", ")", ";", "}", "else", "if", "(", "_omgr", "!=", "null", ")", "{", "_omgr", ".", "postEvent", ...
Posts the specified event either to our dobject manager or to the compound event for which we are currently transacting.
[ "Posts", "the", "specified", "event", "either", "to", "our", "dobject", "manager", "or", "to", "the", "compound", "event", "for", "which", "we", "are", "currently", "transacting", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/dobj/DObject.java#L519-L531
train
threerings/narya
core/src/main/java/com/threerings/presents/dobj/DObject.java
DObject.which
protected void which (StringBuilder buf) { buf.append(StringUtil.shortClassName(this)); buf.append(":").append(_oid); }
java
protected void which (StringBuilder buf) { buf.append(StringUtil.shortClassName(this)); buf.append(":").append(_oid); }
[ "protected", "void", "which", "(", "StringBuilder", "buf", ")", "{", "buf", ".", "append", "(", "StringUtil", ".", "shortClassName", "(", "this", ")", ")", ";", "buf", ".", "append", "(", "\":\"", ")", ".", "append", "(", "_oid", ")", ";", "}" ]
Used to briefly describe this distributed object.
[ "Used", "to", "briefly", "describe", "this", "distributed", "object", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/dobj/DObject.java#L681-L685
train
threerings/narya
core/src/main/java/com/threerings/presents/dobj/DObject.java
DObject.commitTransaction
public void commitTransaction () { if (_tevent == null) { String errmsg = "Cannot commit: not involved in a transaction [dobj=" + this + "]"; throw new IllegalStateException(errmsg); } // if we are nested, we decrement our nesting count rather than committing the transaction if (_tcount > 0) { _tcount--; } else { // we may actually be doing our final commit after someone already cancelled this // transaction, so we need to perform the appropriate action at this point if (_tcancelled) { _tevent.cancel(); } else { _tevent.commit(); } } }
java
public void commitTransaction () { if (_tevent == null) { String errmsg = "Cannot commit: not involved in a transaction [dobj=" + this + "]"; throw new IllegalStateException(errmsg); } // if we are nested, we decrement our nesting count rather than committing the transaction if (_tcount > 0) { _tcount--; } else { // we may actually be doing our final commit after someone already cancelled this // transaction, so we need to perform the appropriate action at this point if (_tcancelled) { _tevent.cancel(); } else { _tevent.commit(); } } }
[ "public", "void", "commitTransaction", "(", ")", "{", "if", "(", "_tevent", "==", "null", ")", "{", "String", "errmsg", "=", "\"Cannot commit: not involved in a transaction [dobj=\"", "+", "this", "+", "\"]\"", ";", "throw", "new", "IllegalStateException", "(", "e...
Commits the transaction in which this distributed object is involved. @see CompoundEvent#commit
[ "Commits", "the", "transaction", "in", "which", "this", "distributed", "object", "is", "involved", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/dobj/DObject.java#L741-L761
train
threerings/narya
core/src/main/java/com/threerings/presents/dobj/DObject.java
DObject.cancelTransaction
public void cancelTransaction () { if (_tevent == null) { String errmsg = "Cannot cancel: not involved in a transaction [dobj=" + this + "]"; throw new IllegalStateException(errmsg); } // if we're in a nested transaction, make a note that it is to be cancelled when all // parties commit and decrement the nest count if (_tcount > 0) { _tcancelled = true; _tcount--; } else { _tevent.cancel(); } }
java
public void cancelTransaction () { if (_tevent == null) { String errmsg = "Cannot cancel: not involved in a transaction [dobj=" + this + "]"; throw new IllegalStateException(errmsg); } // if we're in a nested transaction, make a note that it is to be cancelled when all // parties commit and decrement the nest count if (_tcount > 0) { _tcancelled = true; _tcount--; } else { _tevent.cancel(); } }
[ "public", "void", "cancelTransaction", "(", ")", "{", "if", "(", "_tevent", "==", "null", ")", "{", "String", "errmsg", "=", "\"Cannot cancel: not involved in a transaction [dobj=\"", "+", "this", "+", "\"]\"", ";", "throw", "new", "IllegalStateException", "(", "e...
Cancels the transaction in which this distributed object is involved. @see CompoundEvent#cancel
[ "Cancels", "the", "transaction", "in", "which", "this", "distributed", "object", "is", "involved", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/dobj/DObject.java#L776-L792
train
threerings/narya
core/src/main/java/com/threerings/presents/dobj/DObject.java
DObject.requestOidAdd
protected void requestOidAdd (String name, OidList list, int oid) { // if we're on the authoritative server, we update the set immediately boolean applyImmediately = isAuthoritative(); if (applyImmediately) { list.add(oid); } postEvent(new ObjectAddedEvent(_oid, name, oid).setAlreadyApplied(applyImmediately)); }
java
protected void requestOidAdd (String name, OidList list, int oid) { // if we're on the authoritative server, we update the set immediately boolean applyImmediately = isAuthoritative(); if (applyImmediately) { list.add(oid); } postEvent(new ObjectAddedEvent(_oid, name, oid).setAlreadyApplied(applyImmediately)); }
[ "protected", "void", "requestOidAdd", "(", "String", "name", ",", "OidList", "list", ",", "int", "oid", ")", "{", "// if we're on the authoritative server, we update the set immediately", "boolean", "applyImmediately", "=", "isAuthoritative", "(", ")", ";", "if", "(", ...
Calls by derived instances when an oid adder method was called.
[ "Calls", "by", "derived", "instances", "when", "an", "oid", "adder", "method", "was", "called", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/dobj/DObject.java#L851-L859
train
threerings/narya
core/src/main/java/com/threerings/presents/dobj/DObject.java
DObject.requestOidRemove
protected void requestOidRemove (String name, OidList list, int oid) { // if we're on the authoritative server, we update the set immediately boolean applyImmediately = isAuthoritative(); if (applyImmediately) { list.remove(oid); } // dispatch an object removed event postEvent(new ObjectRemovedEvent(_oid, name, oid).setAlreadyApplied(applyImmediately)); }
java
protected void requestOidRemove (String name, OidList list, int oid) { // if we're on the authoritative server, we update the set immediately boolean applyImmediately = isAuthoritative(); if (applyImmediately) { list.remove(oid); } // dispatch an object removed event postEvent(new ObjectRemovedEvent(_oid, name, oid).setAlreadyApplied(applyImmediately)); }
[ "protected", "void", "requestOidRemove", "(", "String", "name", ",", "OidList", "list", ",", "int", "oid", ")", "{", "// if we're on the authoritative server, we update the set immediately", "boolean", "applyImmediately", "=", "isAuthoritative", "(", ")", ";", "if", "("...
Calls by derived instances when an oid remover method was called.
[ "Calls", "by", "derived", "instances", "when", "an", "oid", "remover", "method", "was", "called", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/dobj/DObject.java#L864-L873
train
threerings/narya
core/src/main/java/com/threerings/presents/dobj/DObject.java
DObject.requestEntryAdd
protected <T extends DSet.Entry> void requestEntryAdd (String name, DSet<T> set, T entry) { // if we're on the authoritative server, we update the set immediately boolean applyImmediately = isAuthoritative(); if (applyImmediately) { set.add(entry); } // dispatch an entry added event postEvent(new EntryAddedEvent<T>(_oid, name, entry).setAlreadyApplied(applyImmediately)); }
java
protected <T extends DSet.Entry> void requestEntryAdd (String name, DSet<T> set, T entry) { // if we're on the authoritative server, we update the set immediately boolean applyImmediately = isAuthoritative(); if (applyImmediately) { set.add(entry); } // dispatch an entry added event postEvent(new EntryAddedEvent<T>(_oid, name, entry).setAlreadyApplied(applyImmediately)); }
[ "protected", "<", "T", "extends", "DSet", ".", "Entry", ">", "void", "requestEntryAdd", "(", "String", "name", ",", "DSet", "<", "T", ">", "set", ",", "T", "entry", ")", "{", "// if we're on the authoritative server, we update the set immediately", "boolean", "app...
Calls by derived instances when a set adder method was called.
[ "Calls", "by", "derived", "instances", "when", "a", "set", "adder", "method", "was", "called", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/dobj/DObject.java#L890-L899
train
threerings/narya
core/src/main/java/com/threerings/presents/dobj/DObject.java
DObject.requestEntryRemove
protected <T extends DSet.Entry> void requestEntryRemove ( String name, DSet<T> set, Comparable<?> key) { // if we're on the authoritative server, we update the set immediately T oldEntry = null; if (isAuthoritative()) { oldEntry = set.removeKey(key); if (oldEntry == null) { log.warning("Requested to remove non-element", "set", name, "key", key, new Exception()); } } // dispatch an entry removed event postEvent(new EntryRemovedEvent<T>(_oid, name, key).setOldEntry(oldEntry)); }
java
protected <T extends DSet.Entry> void requestEntryRemove ( String name, DSet<T> set, Comparable<?> key) { // if we're on the authoritative server, we update the set immediately T oldEntry = null; if (isAuthoritative()) { oldEntry = set.removeKey(key); if (oldEntry == null) { log.warning("Requested to remove non-element", "set", name, "key", key, new Exception()); } } // dispatch an entry removed event postEvent(new EntryRemovedEvent<T>(_oid, name, key).setOldEntry(oldEntry)); }
[ "protected", "<", "T", "extends", "DSet", ".", "Entry", ">", "void", "requestEntryRemove", "(", "String", "name", ",", "DSet", "<", "T", ">", "set", ",", "Comparable", "<", "?", ">", "key", ")", "{", "// if we're on the authoritative server, we update the set im...
Calls by derived instances when a set remover method was called.
[ "Calls", "by", "derived", "instances", "when", "a", "set", "remover", "method", "was", "called", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/dobj/DObject.java#L904-L918
train
threerings/narya
core/src/main/java/com/threerings/presents/dobj/DObject.java
DObject.createAccessors
protected Accessor[] createAccessors () { Field[] fields = getClass().getFields(); // assume we have one static field for every non-static field List<Accessor> accs = Lists.newArrayListWithExpectedSize(fields.length/2); for (Field field : fields) { if (!Modifier.isStatic(field.getModifiers())) { // skip static fields accs.add(new Accessor.ByField(field)); } } return accs.toArray(new Accessor[accs.size()]); }
java
protected Accessor[] createAccessors () { Field[] fields = getClass().getFields(); // assume we have one static field for every non-static field List<Accessor> accs = Lists.newArrayListWithExpectedSize(fields.length/2); for (Field field : fields) { if (!Modifier.isStatic(field.getModifiers())) { // skip static fields accs.add(new Accessor.ByField(field)); } } return accs.toArray(new Accessor[accs.size()]); }
[ "protected", "Accessor", "[", "]", "createAccessors", "(", ")", "{", "Field", "[", "]", "fields", "=", "getClass", "(", ")", ".", "getFields", "(", ")", ";", "// assume we have one static field for every non-static field", "List", "<", "Accessor", ">", "accs", "...
Creates the accessors that will be used to read and write this object's attributes. The default implementation assumes the object's attributes are all public fields and uses reflection to get and set their values.
[ "Creates", "the", "accessors", "that", "will", "be", "used", "to", "read", "and", "write", "this", "object", "s", "attributes", ".", "The", "default", "implementation", "assumes", "the", "object", "s", "attributes", "are", "all", "public", "fields", "and", "...
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/dobj/DObject.java#L980-L991
train
threerings/narya
core/src/main/java/com/threerings/presents/dobj/DObject.java
DObject.getListenerIndex
protected int getListenerIndex (ChangeListener listener) { if (_listeners == null) { return -1; } for (int ii = 0, ll = _listeners.length; ii < ll; ii++) { Object olistener = _listeners[ii]; if (olistener == listener || (olistener instanceof WeakReference<?> && ((WeakReference<?>)olistener).get() == listener)) { return ii; } } return -1; }
java
protected int getListenerIndex (ChangeListener listener) { if (_listeners == null) { return -1; } for (int ii = 0, ll = _listeners.length; ii < ll; ii++) { Object olistener = _listeners[ii]; if (olistener == listener || (olistener instanceof WeakReference<?> && ((WeakReference<?>)olistener).get() == listener)) { return ii; } } return -1; }
[ "protected", "int", "getListenerIndex", "(", "ChangeListener", "listener", ")", "{", "if", "(", "_listeners", "==", "null", ")", "{", "return", "-", "1", ";", "}", "for", "(", "int", "ii", "=", "0", ",", "ll", "=", "_listeners", ".", "length", ";", "...
Returns the index of the identified listener, or -1 if not found.
[ "Returns", "the", "index", "of", "the", "identified", "listener", "or", "-", "1", "if", "not", "found", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/dobj/DObject.java#L996-L1009
train
threerings/narya
core/src/main/java/com/threerings/admin/server/AdminManager.java
AdminManager.getConfigInfo
public void getConfigInfo (ClientObject caller, AdminService.ConfigInfoListener listener) throws InvocationException { // we don't have to validate the request because the user can't do anything with the keys // or oids unless they're an admin (we put the burden of doing that checking on the creator // of the config object because we would otherwise need some mechanism to determine whether // a user is an admin and we don't want to force some primitive system on the service user) String[] keys = _registry.getKeys(); int[] oids = new int[keys.length]; for (int ii = 0; ii < keys.length; ii++) { oids[ii] = _registry.getObject(keys[ii]).getOid(); } listener.gotConfigInfo(keys, oids); }
java
public void getConfigInfo (ClientObject caller, AdminService.ConfigInfoListener listener) throws InvocationException { // we don't have to validate the request because the user can't do anything with the keys // or oids unless they're an admin (we put the burden of doing that checking on the creator // of the config object because we would otherwise need some mechanism to determine whether // a user is an admin and we don't want to force some primitive system on the service user) String[] keys = _registry.getKeys(); int[] oids = new int[keys.length]; for (int ii = 0; ii < keys.length; ii++) { oids[ii] = _registry.getObject(keys[ii]).getOid(); } listener.gotConfigInfo(keys, oids); }
[ "public", "void", "getConfigInfo", "(", "ClientObject", "caller", ",", "AdminService", ".", "ConfigInfoListener", "listener", ")", "throws", "InvocationException", "{", "// we don't have to validate the request because the user can't do anything with the keys", "// or oids unless the...
from interface AdminProvider
[ "from", "interface", "AdminProvider" ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/admin/server/AdminManager.java#L48-L61
train
threerings/narya
core/src/main/java/com/threerings/presents/net/ServiceCreds.java
ServiceCreds.createAuthToken
protected static String createAuthToken (String clientId, String sharedSecret) { return StringUtil.md5hex(clientId + sharedSecret); }
java
protected static String createAuthToken (String clientId, String sharedSecret) { return StringUtil.md5hex(clientId + sharedSecret); }
[ "protected", "static", "String", "createAuthToken", "(", "String", "clientId", ",", "String", "sharedSecret", ")", "{", "return", "StringUtil", ".", "md5hex", "(", "clientId", "+", "sharedSecret", ")", ";", "}" ]
Creates a unique password for the specified node using the supplied shared secret.
[ "Creates", "a", "unique", "password", "for", "the", "specified", "node", "using", "the", "supplied", "shared", "secret", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/net/ServiceCreds.java#L68-L71
train
threerings/narya
core/src/main/java/com/threerings/nio/conman/ServerSocketChannelAcceptor.java
ServerSocketChannelAcceptor.bind
public boolean bind () { // open our TCP listening ports int successes = 0; for (int port : _ports) { try { acceptConnections(port); successes++; } catch (IOException ioe) { log.warning("Failure listening to socket", "hostname", _bindHostname, "port", port, ioe); } } return successes > 0; }
java
public boolean bind () { // open our TCP listening ports int successes = 0; for (int port : _ports) { try { acceptConnections(port); successes++; } catch (IOException ioe) { log.warning("Failure listening to socket", "hostname", _bindHostname, "port", port, ioe); } } return successes > 0; }
[ "public", "boolean", "bind", "(", ")", "{", "// open our TCP listening ports", "int", "successes", "=", "0", ";", "for", "(", "int", "port", ":", "_ports", ")", "{", "try", "{", "acceptConnections", "(", "port", ")", ";", "successes", "++", ";", "}", "ca...
Bind to the socket ports and return true if any of the binds succeeded.
[ "Bind", "to", "the", "socket", "ports", "and", "return", "true", "if", "any", "of", "the", "binds", "succeeded", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/nio/conman/ServerSocketChannelAcceptor.java#L67-L81
train
threerings/narya
core/src/main/java/com/threerings/nio/conman/ServerSocketChannelAcceptor.java
ServerSocketChannelAcceptor.shutdown
public void shutdown () { for (ServerSocketChannel ssocket : _ssockets) { try { ssocket.socket().close(); } catch (IOException ioe) { log.warning("Failed to close listening socket: " + ssocket, ioe); } } }
java
public void shutdown () { for (ServerSocketChannel ssocket : _ssockets) { try { ssocket.socket().close(); } catch (IOException ioe) { log.warning("Failed to close listening socket: " + ssocket, ioe); } } }
[ "public", "void", "shutdown", "(", ")", "{", "for", "(", "ServerSocketChannel", "ssocket", ":", "_ssockets", ")", "{", "try", "{", "ssocket", ".", "socket", "(", ")", ".", "close", "(", ")", ";", "}", "catch", "(", "IOException", "ioe", ")", "{", "lo...
Unbind our listening sockets.
[ "Unbind", "our", "listening", "sockets", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/nio/conman/ServerSocketChannelAcceptor.java#L86-L95
train
threerings/narya
tools/src/main/java/com/threerings/presents/tools/InvocationTask.java
InvocationTask.createAndGatherImports
public ServiceMethod createAndGatherImports (Method method, ImportSet imports) { ServiceMethod sm = new ServiceMethod(method); sm.gatherImports(imports); return sm; }
java
public ServiceMethod createAndGatherImports (Method method, ImportSet imports) { ServiceMethod sm = new ServiceMethod(method); sm.gatherImports(imports); return sm; }
[ "public", "ServiceMethod", "createAndGatherImports", "(", "Method", "method", ",", "ImportSet", "imports", ")", "{", "ServiceMethod", "sm", "=", "new", "ServiceMethod", "(", "method", ")", ";", "sm", ".", "gatherImports", "(", "imports", ")", ";", "return", "s...
Creates a new service method and adds its basic imports to a set. @param method the method to create @param imports will be filled with the types required by the method
[ "Creates", "a", "new", "service", "method", "and", "adds", "its", "basic", "imports", "to", "a", "set", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/tools/src/main/java/com/threerings/presents/tools/InvocationTask.java#L95-L100
train
threerings/narya
core/src/main/java/com/threerings/presents/data/TimeBaseObject.java
TimeBaseObject.getDelta
protected long getDelta (long timeStamp, long maxValue) { boolean even = (evenBase > oddBase); long base = even ? evenBase : oddBase; long delta = timeStamp - base; // make sure this timestamp is not sufficiently old that we can't // generate a delta time with it if (delta < 0) { String errmsg = "Time stamp too old for conversion to delta time"; throw new IllegalArgumentException(errmsg); } // see if it's time to swap if (delta > maxValue) { if (even) { setOddBase(timeStamp); } else { setEvenBase(timeStamp); } delta = 0; } // if we're odd, we need to mark the value as such if (!even) { delta = (-1 - delta); } return delta; }
java
protected long getDelta (long timeStamp, long maxValue) { boolean even = (evenBase > oddBase); long base = even ? evenBase : oddBase; long delta = timeStamp - base; // make sure this timestamp is not sufficiently old that we can't // generate a delta time with it if (delta < 0) { String errmsg = "Time stamp too old for conversion to delta time"; throw new IllegalArgumentException(errmsg); } // see if it's time to swap if (delta > maxValue) { if (even) { setOddBase(timeStamp); } else { setEvenBase(timeStamp); } delta = 0; } // if we're odd, we need to mark the value as such if (!even) { delta = (-1 - delta); } return delta; }
[ "protected", "long", "getDelta", "(", "long", "timeStamp", ",", "long", "maxValue", ")", "{", "boolean", "even", "=", "(", "evenBase", ">", "oddBase", ")", ";", "long", "base", "=", "even", "?", "evenBase", ":", "oddBase", ";", "long", "delta", "=", "t...
Obtains a delta with the specified maximum value, swapping from even to odd, if necessary.
[ "Obtains", "a", "delta", "with", "the", "specified", "maximum", "value", "swapping", "from", "even", "to", "odd", "if", "necessary", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/data/TimeBaseObject.java#L103-L132
train
threerings/narya
core/src/main/java/com/threerings/presents/data/ClientObject.java
ClientObject.checkAccess
public String checkAccess (Permission perm, Object context) { if (_permPolicy == null) { _permPolicy = createPermissionPolicy(); } return _permPolicy.checkAccess(perm, context); }
java
public String checkAccess (Permission perm, Object context) { if (_permPolicy == null) { _permPolicy = createPermissionPolicy(); } return _permPolicy.checkAccess(perm, context); }
[ "public", "String", "checkAccess", "(", "Permission", "perm", ",", "Object", "context", ")", "{", "if", "(", "_permPolicy", "==", "null", ")", "{", "_permPolicy", "=", "createPermissionPolicy", "(", ")", ";", "}", "return", "_permPolicy", ".", "checkAccess", ...
Checks whether or not this client has the specified permission. @return null if the user has access, a fully-qualified translatable message string indicating the reason for denial of access. @see ClientObject.PermissionPolicy
[ "Checks", "whether", "or", "not", "this", "client", "has", "the", "specified", "permission", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/data/ClientObject.java#L73-L79
train
xbib/marc
src/main/java/org/xbib/marc/transformer/value/MarcValueTransformers.java
MarcValueTransformers.setMarcValueTransformer
public MarcValueTransformers setMarcValueTransformer(String fieldKey, MarcValueTransformer transformer) { // split into tag + indicator and subfield IDs int pos = fieldKey.lastIndexOf('$'); String tagind = pos > 0 ? fieldKey.substring(0, pos) : fieldKey; String subs = pos > 0 ? fieldKey.substring(pos + 1) : ""; this.marcValueTransformerMap.put(tagind, transformer); // subfield IDs this.subfieldMap.put(tagind, subs); return this; }
java
public MarcValueTransformers setMarcValueTransformer(String fieldKey, MarcValueTransformer transformer) { // split into tag + indicator and subfield IDs int pos = fieldKey.lastIndexOf('$'); String tagind = pos > 0 ? fieldKey.substring(0, pos) : fieldKey; String subs = pos > 0 ? fieldKey.substring(pos + 1) : ""; this.marcValueTransformerMap.put(tagind, transformer); // subfield IDs this.subfieldMap.put(tagind, subs); return this; }
[ "public", "MarcValueTransformers", "setMarcValueTransformer", "(", "String", "fieldKey", ",", "MarcValueTransformer", "transformer", ")", "{", "// split into tag + indicator and subfield IDs", "int", "pos", "=", "fieldKey", ".", "lastIndexOf", "(", "'", "'", ")", ";", ...
Set MARC value transformer for transforming field values. @param fieldKey the MARC field key for the field to be transformed @param transformer the string transformer @return this handler
[ "Set", "MARC", "value", "transformer", "for", "transforming", "field", "values", "." ]
d8426fcfc686507cab59b3d8181b08f83718418c
https://github.com/xbib/marc/blob/d8426fcfc686507cab59b3d8181b08f83718418c/src/main/java/org/xbib/marc/transformer/value/MarcValueTransformers.java#L45-L54
train
xbib/marc
src/main/java/org/xbib/marc/transformer/value/MarcValueTransformers.java
MarcValueTransformers.transformValue
public MarcField transformValue(MarcField field) { String key = field.toTagIndicatorKey(); if (marcValueTransformerMap.isEmpty()) { return field; } final MarcValueTransformer transformer = marcValueTransformerMap.containsKey(key) ? marcValueTransformerMap.get(key) : marcValueTransformerMap.get(DEFAULT); if (transformer != null) { MarcField.Builder builder = MarcField.builder(); builder.tag(field.getTag()).indicator(field.getIndicator()); if (field.getValue() != null) { builder.value(transformer.transform(field.getValue())); } // select only subfields configured for this tag String subs = subfieldMap.containsKey(key) ? subfieldMap.get(key) : field.getSubfieldIds(); field.getSubfields().forEach(subfield -> builder.subfield(subfield.getId(), subs.contains(subfield.getId()) ? transformer.transform(subfield.getValue()) : subfield.getValue())); return builder.build(); } return field; }
java
public MarcField transformValue(MarcField field) { String key = field.toTagIndicatorKey(); if (marcValueTransformerMap.isEmpty()) { return field; } final MarcValueTransformer transformer = marcValueTransformerMap.containsKey(key) ? marcValueTransformerMap.get(key) : marcValueTransformerMap.get(DEFAULT); if (transformer != null) { MarcField.Builder builder = MarcField.builder(); builder.tag(field.getTag()).indicator(field.getIndicator()); if (field.getValue() != null) { builder.value(transformer.transform(field.getValue())); } // select only subfields configured for this tag String subs = subfieldMap.containsKey(key) ? subfieldMap.get(key) : field.getSubfieldIds(); field.getSubfields().forEach(subfield -> builder.subfield(subfield.getId(), subs.contains(subfield.getId()) ? transformer.transform(subfield.getValue()) : subfield.getValue())); return builder.build(); } return field; }
[ "public", "MarcField", "transformValue", "(", "MarcField", "field", ")", "{", "String", "key", "=", "field", ".", "toTagIndicatorKey", "(", ")", ";", "if", "(", "marcValueTransformerMap", ".", "isEmpty", "(", ")", ")", "{", "return", "field", ";", "}", "fi...
Transform value. @param field the MARC field where values are transformed @return a new MARC field with transformed values
[ "Transform", "value", "." ]
d8426fcfc686507cab59b3d8181b08f83718418c
https://github.com/xbib/marc/blob/d8426fcfc686507cab59b3d8181b08f83718418c/src/main/java/org/xbib/marc/transformer/value/MarcValueTransformers.java#L61-L82
train
threerings/narya
core/src/main/java/com/threerings/io/ByteBufferOutputStream.java
ByteBufferOutputStream.expand
protected final void expand (int needed) { int ocapacity = _buffer.capacity(); int ncapacity = _buffer.position() + needed; if (ncapacity > ocapacity) { // increase the buffer size in large increments ncapacity = Math.max(ocapacity << 1, ncapacity); ByteBuffer newbuf = ByteBuffer.allocate(ncapacity); newbuf.put((ByteBuffer)_buffer.flip()); _buffer = newbuf; } }
java
protected final void expand (int needed) { int ocapacity = _buffer.capacity(); int ncapacity = _buffer.position() + needed; if (ncapacity > ocapacity) { // increase the buffer size in large increments ncapacity = Math.max(ocapacity << 1, ncapacity); ByteBuffer newbuf = ByteBuffer.allocate(ncapacity); newbuf.put((ByteBuffer)_buffer.flip()); _buffer = newbuf; } }
[ "protected", "final", "void", "expand", "(", "int", "needed", ")", "{", "int", "ocapacity", "=", "_buffer", ".", "capacity", "(", ")", ";", "int", "ncapacity", "=", "_buffer", ".", "position", "(", ")", "+", "needed", ";", "if", "(", "ncapacity", ">", ...
Expands our buffer to accomodate the specified capacity.
[ "Expands", "our", "buffer", "to", "accomodate", "the", "specified", "capacity", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/io/ByteBufferOutputStream.java#L102-L113
train
threerings/narya
core/src/main/java/com/threerings/crowd/chat/data/UserSystemMessage.java
UserSystemMessage.create
public static UserSystemMessage create (Name sender, String message, String bundle) { return new UserSystemMessage(sender, message, bundle, INFO); }
java
public static UserSystemMessage create (Name sender, String message, String bundle) { return new UserSystemMessage(sender, message, bundle, INFO); }
[ "public", "static", "UserSystemMessage", "create", "(", "Name", "sender", ",", "String", "message", ",", "String", "bundle", ")", "{", "return", "new", "UserSystemMessage", "(", "sender", ",", "message", ",", "bundle", ",", "INFO", ")", ";", "}" ]
Construct a INFO-level UserSystemMessage.
[ "Construct", "a", "INFO", "-", "level", "UserSystemMessage", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/crowd/chat/data/UserSystemMessage.java#L38-L41
train
davidmoten/grumpy
grumpy-projection/src/main/java/com/github/davidmoten/grumpy/util/NearBSpline.java
NearBSpline.setLine
public void setLine(int... points) { double[] pd = new double[points.length]; for (int i = 0; i < points.length; i++) { pd[i] = points[i]; } setLine(pd); }
java
public void setLine(int... points) { double[] pd = new double[points.length]; for (int i = 0; i < points.length; i++) { pd[i] = points[i]; } setLine(pd); }
[ "public", "void", "setLine", "(", "int", "...", "points", ")", "{", "double", "[", "]", "pd", "=", "new", "double", "[", "points", ".", "length", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "points", ".", "length", ";", "i", "++"...
Sets the curve using control points given in integer precision @param points the control points for the curve
[ "Sets", "the", "curve", "using", "control", "points", "given", "in", "integer", "precision" ]
f2d03e6b9771f15425fb3f76314837efc08c1233
https://github.com/davidmoten/grumpy/blob/f2d03e6b9771f15425fb3f76314837efc08c1233/grumpy-projection/src/main/java/com/github/davidmoten/grumpy/util/NearBSpline.java#L58-L64
train
davidmoten/grumpy
grumpy-projection/src/main/java/com/github/davidmoten/grumpy/util/NearBSpline.java
NearBSpline.setLine
public void setLine(Point2D[] points) { double[] pd = new double[points.length * 2]; for (int i = 0; i < points.length; i++) { Point2D p = points[i]; pd[i * 2] = p.getX(); pd[i * 2 + 1] = p.getY(); } setLine(pd); }
java
public void setLine(Point2D[] points) { double[] pd = new double[points.length * 2]; for (int i = 0; i < points.length; i++) { Point2D p = points[i]; pd[i * 2] = p.getX(); pd[i * 2 + 1] = p.getY(); } setLine(pd); }
[ "public", "void", "setLine", "(", "Point2D", "[", "]", "points", ")", "{", "double", "[", "]", "pd", "=", "new", "double", "[", "points", ".", "length", "*", "2", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "points", ".", "length...
Sets the curve using control points given as Point2D objects @param points the control points for the curve
[ "Sets", "the", "curve", "using", "control", "points", "given", "as", "Point2D", "objects" ]
f2d03e6b9771f15425fb3f76314837efc08c1233
https://github.com/davidmoten/grumpy/blob/f2d03e6b9771f15425fb3f76314837efc08c1233/grumpy-projection/src/main/java/com/github/davidmoten/grumpy/util/NearBSpline.java#L128-L136
train
threerings/narya
core/src/main/java/com/threerings/presents/server/ClientManager.java
ClientManager.addClientObserver
public void addClientObserver (ClientObserver observer) { _clobservers.add(observer); if (observer instanceof DetailedClientObserver) { _dclobservers.add((DetailedClientObserver)observer); } }
java
public void addClientObserver (ClientObserver observer) { _clobservers.add(observer); if (observer instanceof DetailedClientObserver) { _dclobservers.add((DetailedClientObserver)observer); } }
[ "public", "void", "addClientObserver", "(", "ClientObserver", "observer", ")", "{", "_clobservers", ".", "add", "(", "observer", ")", ";", "if", "(", "observer", "instanceof", "DetailedClientObserver", ")", "{", "_dclobservers", ".", "add", "(", "(", "DetailedCl...
Registers an observer that will be notified when clients start and end their sessions.
[ "Registers", "an", "observer", "that", "will", "be", "notified", "when", "clients", "start", "and", "end", "their", "sessions", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/server/ClientManager.java#L219-L225
train
threerings/narya
core/src/main/java/com/threerings/presents/server/ClientManager.java
ClientManager.applyToClient
public void applyToClient (Name username, final ClientOp clop) { resolveClientObject(username, new ClientResolutionListener() { public void clientResolved (Name username, ClientObject clobj) { try { clop.apply(clobj); } catch (Exception e) { log.warning("Client op failed", "username", username, "clop", clop, e); } finally { releaseClientObject(username); } } public void resolutionFailed (Name username, Exception reason) { clop.resolutionFailed(reason); } }); }
java
public void applyToClient (Name username, final ClientOp clop) { resolveClientObject(username, new ClientResolutionListener() { public void clientResolved (Name username, ClientObject clobj) { try { clop.apply(clobj); } catch (Exception e) { log.warning("Client op failed", "username", username, "clop", clop, e); } finally { releaseClientObject(username); } } public void resolutionFailed (Name username, Exception reason) { clop.resolutionFailed(reason); } }); }
[ "public", "void", "applyToClient", "(", "Name", "username", ",", "final", "ClientOp", "clop", ")", "{", "resolveClientObject", "(", "username", ",", "new", "ClientResolutionListener", "(", ")", "{", "public", "void", "clientResolved", "(", "Name", "username", ",...
Resolves the specified client, applies the supplied client operation to them and releases the client.
[ "Resolves", "the", "specified", "client", "applies", "the", "supplied", "client", "operation", "to", "them", "and", "releases", "the", "client", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/server/ClientManager.java#L262-L281
train
threerings/narya
core/src/main/java/com/threerings/presents/server/ClientManager.java
ClientManager.shutdown
public void shutdown () { log.info("Client manager shutting down", "ccount", _usermap.size()); // inform all of our clients that they are being shut down synchronized (_usermap) { for (PresentsSession pc : _usermap.values()) { try { pc.shutdown(); } catch (Exception e) { log.warning("Client choked in shutdown()", "client", StringUtil.safeToString(pc), e); } } } }
java
public void shutdown () { log.info("Client manager shutting down", "ccount", _usermap.size()); // inform all of our clients that they are being shut down synchronized (_usermap) { for (PresentsSession pc : _usermap.values()) { try { pc.shutdown(); } catch (Exception e) { log.warning("Client choked in shutdown()", "client", StringUtil.safeToString(pc), e); } } } }
[ "public", "void", "shutdown", "(", ")", "{", "log", ".", "info", "(", "\"Client manager shutting down\"", ",", "\"ccount\"", ",", "_usermap", ".", "size", "(", ")", ")", ";", "// inform all of our clients that they are being shut down", "synchronized", "(", "_usermap"...
from interface Lifecycle.Component
[ "from", "interface", "Lifecycle", ".", "Component" ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/server/ClientManager.java#L386-L401
train
threerings/narya
core/src/main/java/com/threerings/presents/server/ClientManager.java
ClientManager.clientResolved
public synchronized void clientResolved (Name username, ClientObject clobj) { // because we added ourselves as a client resolution listener, the client object reference // count was increased, but we're not a real resolver (who would have to call // releaseClientObject() to release their reference), so we release our reference // immediately clobj.release(); // stuff the object into the mapping table _objmap.put(username, clobj); // and remove the resolution listener _penders.remove(username); }
java
public synchronized void clientResolved (Name username, ClientObject clobj) { // because we added ourselves as a client resolution listener, the client object reference // count was increased, but we're not a real resolver (who would have to call // releaseClientObject() to release their reference), so we release our reference // immediately clobj.release(); // stuff the object into the mapping table _objmap.put(username, clobj); // and remove the resolution listener _penders.remove(username); }
[ "public", "synchronized", "void", "clientResolved", "(", "Name", "username", ",", "ClientObject", "clobj", ")", "{", "// because we added ourselves as a client resolution listener, the client object reference", "// count was increased, but we're not a real resolver (who would have to call"...
documentation inherited from interface ClientResolutionListener
[ "documentation", "inherited", "from", "interface", "ClientResolutionListener" ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/server/ClientManager.java#L421-L434
train
threerings/narya
core/src/main/java/com/threerings/presents/server/ClientManager.java
ClientManager.connectionEstablished
public synchronized void connectionEstablished ( PresentsConnection conn, Name authname, AuthRequest req, AuthResponse rsp) { String type = authname.getClass().getSimpleName(); // see if a session is already registered with this name PresentsSession session = getClient(authname); if (session != null) { //log.info("Resuming session", "type", type, "who", authname, "conn", conn); session.resumeSession(req, conn); } else { log.info("Session initiated", "type", type, "who", authname, "conn", conn); // figure out our session class Class<? extends PresentsSession> sessionClass = null; for (SessionFactory factory : _factories) { if ((sessionClass = factory.getSessionClass(req)) != null) { break; } } // create a new session and stick'em in the table session = _injector.getInstance(sessionClass); session.startSession(authname, req, conn, rsp.authdata); // map their session instance synchronized (_usermap) { // we refetch the authname from the session for use in the map in case it decides // to do something crazy like rewrite it in startSession() _usermap.put(session.getAuthName(), session); } } // map this connection to this session _conmap.put(conn, session); }
java
public synchronized void connectionEstablished ( PresentsConnection conn, Name authname, AuthRequest req, AuthResponse rsp) { String type = authname.getClass().getSimpleName(); // see if a session is already registered with this name PresentsSession session = getClient(authname); if (session != null) { //log.info("Resuming session", "type", type, "who", authname, "conn", conn); session.resumeSession(req, conn); } else { log.info("Session initiated", "type", type, "who", authname, "conn", conn); // figure out our session class Class<? extends PresentsSession> sessionClass = null; for (SessionFactory factory : _factories) { if ((sessionClass = factory.getSessionClass(req)) != null) { break; } } // create a new session and stick'em in the table session = _injector.getInstance(sessionClass); session.startSession(authname, req, conn, rsp.authdata); // map their session instance synchronized (_usermap) { // we refetch the authname from the session for use in the map in case it decides // to do something crazy like rewrite it in startSession() _usermap.put(session.getAuthName(), session); } } // map this connection to this session _conmap.put(conn, session); }
[ "public", "synchronized", "void", "connectionEstablished", "(", "PresentsConnection", "conn", ",", "Name", "authname", ",", "AuthRequest", "req", ",", "AuthResponse", "rsp", ")", "{", "String", "type", "=", "authname", ".", "getClass", "(", ")", ".", "getSimpleN...
Called by the connection manager to let us know when a new connection has been established.
[ "Called", "by", "the", "connection", "manager", "to", "let", "us", "know", "when", "a", "new", "connection", "has", "been", "established", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/server/ClientManager.java#L446-L481
train
threerings/narya
core/src/main/java/com/threerings/presents/server/ClientManager.java
ClientManager.connectionFailed
public synchronized void connectionFailed (Connection conn, IOException fault) { // remove the session from the connection map PresentsSession session = _conmap.remove(conn); if (session != null) { log.info("Unmapped failed session", "session", session, "conn", conn, "fault", fault); // let the session know the connection went away session.wasUnmapped(); // and let the session know things went haywire session.connectionFailed(fault); } else if (!(conn instanceof AuthingConnection)) { log.info("Unmapped connection failed?", "conn", conn, "fault", fault, new Exception()); } }
java
public synchronized void connectionFailed (Connection conn, IOException fault) { // remove the session from the connection map PresentsSession session = _conmap.remove(conn); if (session != null) { log.info("Unmapped failed session", "session", session, "conn", conn, "fault", fault); // let the session know the connection went away session.wasUnmapped(); // and let the session know things went haywire session.connectionFailed(fault); } else if (!(conn instanceof AuthingConnection)) { log.info("Unmapped connection failed?", "conn", conn, "fault", fault, new Exception()); } }
[ "public", "synchronized", "void", "connectionFailed", "(", "Connection", "conn", ",", "IOException", "fault", ")", "{", "// remove the session from the connection map", "PresentsSession", "session", "=", "_conmap", ".", "remove", "(", "conn", ")", ";", "if", "(", "s...
Called by the connection manager to let us know when a connection has failed.
[ "Called", "by", "the", "connection", "manager", "to", "let", "us", "know", "when", "a", "connection", "has", "failed", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/server/ClientManager.java#L486-L500
train
threerings/narya
core/src/main/java/com/threerings/presents/server/ClientManager.java
ClientManager.connectionClosed
public synchronized void connectionClosed (Connection conn) { // remove the session from the connection map PresentsSession session = _conmap.remove(conn); if (session != null) { log.debug("Unmapped session", "session", session, "conn", conn); // let the session know the connection went away session.wasUnmapped(); } else { log.debug("Closed unmapped connection '" + conn + "'. " + "Session probably not yet authenticated."); } }
java
public synchronized void connectionClosed (Connection conn) { // remove the session from the connection map PresentsSession session = _conmap.remove(conn); if (session != null) { log.debug("Unmapped session", "session", session, "conn", conn); // let the session know the connection went away session.wasUnmapped(); } else { log.debug("Closed unmapped connection '" + conn + "'. " + "Session probably not yet authenticated."); } }
[ "public", "synchronized", "void", "connectionClosed", "(", "Connection", "conn", ")", "{", "// remove the session from the connection map", "PresentsSession", "session", "=", "_conmap", ".", "remove", "(", "conn", ")", ";", "if", "(", "session", "!=", "null", ")", ...
Called by the connection manager to let us know when a connection has been closed.
[ "Called", "by", "the", "connection", "manager", "to", "let", "us", "know", "when", "a", "connection", "has", "been", "closed", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/server/ClientManager.java#L505-L518
train
threerings/narya
core/src/main/java/com/threerings/presents/server/ClientManager.java
ClientManager.appendReport
public void appendReport (StringBuilder report, long now, long sinceLast, boolean reset) { report.append("* presents.ClientManager:\n"); report.append("- Sessions: "); synchronized (_usermap) { report.append(_usermap.size()).append(" total, "); } report.append(_conmap.size()).append(" connected, "); report.append(_penders.size()).append(" pending\n"); report.append("- Mapped users: ").append(_objmap.size()).append("\n"); }
java
public void appendReport (StringBuilder report, long now, long sinceLast, boolean reset) { report.append("* presents.ClientManager:\n"); report.append("- Sessions: "); synchronized (_usermap) { report.append(_usermap.size()).append(" total, "); } report.append(_conmap.size()).append(" connected, "); report.append(_penders.size()).append(" pending\n"); report.append("- Mapped users: ").append(_objmap.size()).append("\n"); }
[ "public", "void", "appendReport", "(", "StringBuilder", "report", ",", "long", "now", ",", "long", "sinceLast", ",", "boolean", "reset", ")", "{", "report", ".", "append", "(", "\"* presents.ClientManager:\\n\"", ")", ";", "report", ".", "append", "(", "\"- Se...
documentation inherited from interface ReportManager.Reporter
[ "documentation", "inherited", "from", "interface", "ReportManager", ".", "Reporter" ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/server/ClientManager.java#L521-L531
train
threerings/narya
core/src/main/java/com/threerings/presents/server/ClientManager.java
ClientManager.clientSessionWillEnd
@EventThread protected void clientSessionWillEnd (final PresentsSession session) { // notify the observers that the session is ended _dclobservers.apply(new ObserverList.ObserverOp<DetailedClientObserver>() { public boolean apply (DetailedClientObserver observer) { observer.clientSessionWillEnd(session); return true; } }); }
java
@EventThread protected void clientSessionWillEnd (final PresentsSession session) { // notify the observers that the session is ended _dclobservers.apply(new ObserverList.ObserverOp<DetailedClientObserver>() { public boolean apply (DetailedClientObserver observer) { observer.clientSessionWillEnd(session); return true; } }); }
[ "@", "EventThread", "protected", "void", "clientSessionWillEnd", "(", "final", "PresentsSession", "session", ")", "{", "// notify the observers that the session is ended", "_dclobservers", ".", "apply", "(", "new", "ObserverList", ".", "ObserverOp", "<", "DetailedClientObse...
Called by PresentsSession when it is about to end its session.
[ "Called", "by", "PresentsSession", "when", "it", "is", "about", "to", "end", "its", "session", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/server/ClientManager.java#L551-L561
train
threerings/narya
core/src/main/java/com/threerings/presents/server/ClientManager.java
ClientManager.clientSessionDidEnd
@EventThread protected void clientSessionDidEnd (final PresentsSession session) { // notify the observers that the session is ended _clobservers.apply(new ObserverList.ObserverOp<ClientObserver>() { public boolean apply (ClientObserver observer) { observer.clientSessionDidEnd(session); return true; } }); }
java
@EventThread protected void clientSessionDidEnd (final PresentsSession session) { // notify the observers that the session is ended _clobservers.apply(new ObserverList.ObserverOp<ClientObserver>() { public boolean apply (ClientObserver observer) { observer.clientSessionDidEnd(session); return true; } }); }
[ "@", "EventThread", "protected", "void", "clientSessionDidEnd", "(", "final", "PresentsSession", "session", ")", "{", "// notify the observers that the session is ended", "_clobservers", ".", "apply", "(", "new", "ObserverList", ".", "ObserverOp", "<", "ClientObserver", "...
Called by PresentsSession when it has ended its session.
[ "Called", "by", "PresentsSession", "when", "it", "has", "ended", "its", "session", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/server/ClientManager.java#L566-L576
train
threerings/narya
core/src/main/java/com/threerings/presents/server/ClientManager.java
ClientManager.clearSession
protected void clearSession (PresentsSession session) { // remove the session from the username map PresentsSession rc; synchronized (_usermap) { rc = _usermap.remove(session.getAuthName()); } // sanity check just because we can if (rc == null) { log.info("Cleared session: unregistered!", "session", session); } else if (rc != session) { log.info("Cleared session: multiple!", "s1", rc, "s2", session); } else { log.info("Cleared session", "session", session); } }
java
protected void clearSession (PresentsSession session) { // remove the session from the username map PresentsSession rc; synchronized (_usermap) { rc = _usermap.remove(session.getAuthName()); } // sanity check just because we can if (rc == null) { log.info("Cleared session: unregistered!", "session", session); } else if (rc != session) { log.info("Cleared session: multiple!", "s1", rc, "s2", session); } else { log.info("Cleared session", "session", session); } }
[ "protected", "void", "clearSession", "(", "PresentsSession", "session", ")", "{", "// remove the session from the username map", "PresentsSession", "rc", ";", "synchronized", "(", "_usermap", ")", "{", "rc", "=", "_usermap", ".", "remove", "(", "session", ".", "getA...
Called by PresentsSession to let us know that we can clear it entirely out of the system.
[ "Called", "by", "PresentsSession", "to", "let", "us", "know", "that", "we", "can", "clear", "it", "entirely", "out", "of", "the", "system", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/server/ClientManager.java#L581-L597
train
threerings/narya
core/src/main/java/com/threerings/presents/server/ClientManager.java
ClientManager.flushSessions
protected void flushSessions () { List<PresentsSession> victims = Lists.newArrayList(); long now = System.currentTimeMillis(); // first build a list of our victims synchronized (_usermap) { for (PresentsSession session : _usermap.values()) { if (session.checkExpired(now)) { victims.add(session); } } } // now end their sessions for (PresentsSession session : victims) { try { log.info("Session expired, ending session", "session", session, "dtime", (now-session.getNetworkStamp()) + "ms]."); session.endSession(); } catch (Exception e) { log.warning("Choke while flushing session", "victim", session, e); } } }
java
protected void flushSessions () { List<PresentsSession> victims = Lists.newArrayList(); long now = System.currentTimeMillis(); // first build a list of our victims synchronized (_usermap) { for (PresentsSession session : _usermap.values()) { if (session.checkExpired(now)) { victims.add(session); } } } // now end their sessions for (PresentsSession session : victims) { try { log.info("Session expired, ending session", "session", session, "dtime", (now-session.getNetworkStamp()) + "ms]."); session.endSession(); } catch (Exception e) { log.warning("Choke while flushing session", "victim", session, e); } } }
[ "protected", "void", "flushSessions", "(", ")", "{", "List", "<", "PresentsSession", ">", "victims", "=", "Lists", ".", "newArrayList", "(", ")", ";", "long", "now", "=", "System", ".", "currentTimeMillis", "(", ")", ";", "// first build a list of our victims", ...
Called once per minute to check for sessions that have been disconnected too long and forcibly end their sessions.
[ "Called", "once", "per", "minute", "to", "check", "for", "sessions", "that", "have", "been", "disconnected", "too", "long", "and", "forcibly", "end", "their", "sessions", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/server/ClientManager.java#L603-L627
train
dkpro/dkpro-argumentation
dkpro-argumentation-preprocessing/src/main/java/org/dkpro/argumentation/preprocessing/annotation/ArgumentTokenBIOAnnotator.java
ArgumentTokenBIOAnnotator.getLabel
protected String getLabel(ArgumentComponent argumentComponent, Token token) { StringBuilder sb = new StringBuilder(argumentComponent.getClass().getSimpleName()); if ("BIO".equals(this.codingGranularity)) { // Does the component begin here? if (argumentComponent.getBegin() == token.getBegin()) { sb.append(B_SUFFIX); } else { sb.append(I_SUFFIX); } } else { sb.append(I_SUFFIX); } return sb.toString(); }
java
protected String getLabel(ArgumentComponent argumentComponent, Token token) { StringBuilder sb = new StringBuilder(argumentComponent.getClass().getSimpleName()); if ("BIO".equals(this.codingGranularity)) { // Does the component begin here? if (argumentComponent.getBegin() == token.getBegin()) { sb.append(B_SUFFIX); } else { sb.append(I_SUFFIX); } } else { sb.append(I_SUFFIX); } return sb.toString(); }
[ "protected", "String", "getLabel", "(", "ArgumentComponent", "argumentComponent", ",", "Token", "token", ")", "{", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", "argumentComponent", ".", "getClass", "(", ")", ".", "getSimpleName", "(", ")", ")", ";", ...
Returns a label for the annotated token @param argumentComponent covering argument component @param token token @return BIO label
[ "Returns", "a", "label", "for", "the", "annotated", "token" ]
57ce6f5e73d8075b7088aeeebb107c85b3d4bbcb
https://github.com/dkpro/dkpro-argumentation/blob/57ce6f5e73d8075b7088aeeebb107c85b3d4bbcb/dkpro-argumentation-preprocessing/src/main/java/org/dkpro/argumentation/preprocessing/annotation/ArgumentTokenBIOAnnotator.java#L69-L87
train
threerings/narya
core/src/main/java/com/threerings/presents/client/ClientCommunicator.java
ClientCommunicator.clearPPI
protected synchronized boolean clearPPI (boolean cancel) { if (_prefPortInterval != null) { if (cancel) { _prefPortInterval.cancel(); _prefPortInterval.failed(); } _prefPortInterval = null; return true; } return false; }
java
protected synchronized boolean clearPPI (boolean cancel) { if (_prefPortInterval != null) { if (cancel) { _prefPortInterval.cancel(); _prefPortInterval.failed(); } _prefPortInterval = null; return true; } return false; }
[ "protected", "synchronized", "boolean", "clearPPI", "(", "boolean", "cancel", ")", "{", "if", "(", "_prefPortInterval", "!=", "null", ")", "{", "if", "(", "cancel", ")", "{", "_prefPortInterval", ".", "cancel", "(", ")", ";", "_prefPortInterval", ".", "faile...
Cancels our preferred port saving interval. This method is called from the communication reader thread and the interval thread and must thus be synchronized.
[ "Cancels", "our", "preferred", "port", "saving", "interval", ".", "This", "method", "is", "called", "from", "the", "communication", "reader", "thread", "and", "the", "interval", "thread", "and", "must", "thus", "be", "synchronized", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/client/ClientCommunicator.java#L125-L136
train
threerings/narya
core/src/main/java/com/threerings/presents/peer/server/EHCachePeerCoordinator.java
EHCachePeerCoordinator.createCachePeerProvider
@Override public CacheManagerPeerProvider createCachePeerProvider ( CacheManager cacheManager, Properties properties) { if (_instance == null) { _instance = new Provider(cacheManager); } return _instance; }
java
@Override public CacheManagerPeerProvider createCachePeerProvider ( CacheManager cacheManager, Properties properties) { if (_instance == null) { _instance = new Provider(cacheManager); } return _instance; }
[ "@", "Override", "public", "CacheManagerPeerProvider", "createCachePeerProvider", "(", "CacheManager", "cacheManager", ",", "Properties", "properties", ")", "{", "if", "(", "_instance", "==", "null", ")", "{", "_instance", "=", "new", "Provider", "(", "cacheManager"...
Return our provider, creating it if needed.
[ "Return", "our", "provider", "creating", "it", "if", "needed", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/peer/server/EHCachePeerCoordinator.java#L69-L77
train
xbib/marc
src/main/java/org/xbib/marc/io/BaseChunkStream.java
BaseChunkStream.chunks
@Override public Stream<Chunk<byte[], BytesReference>> chunks() { Iterator<Chunk<byte[], BytesReference>> iterator = new Iterator<Chunk<byte[], BytesReference>>() { Chunk<byte[], BytesReference> nextData = null; @Override public boolean hasNext() { if (nextData != null) { return true; } else { try { nextData = readChunk(); return nextData != null; } catch (IOException e) { throw new UncheckedIOException(e); } } } @Override public Chunk<byte[], BytesReference> next() { if (nextData != null || hasNext()) { Chunk<byte[], BytesReference> data = nextData; nextData = null; return data; } else { throw new NoSuchElementException(); } } }; return StreamSupport.stream(Spliterators.spliteratorUnknownSize(iterator, Spliterator.ORDERED | Spliterator.NONNULL), false); }
java
@Override public Stream<Chunk<byte[], BytesReference>> chunks() { Iterator<Chunk<byte[], BytesReference>> iterator = new Iterator<Chunk<byte[], BytesReference>>() { Chunk<byte[], BytesReference> nextData = null; @Override public boolean hasNext() { if (nextData != null) { return true; } else { try { nextData = readChunk(); return nextData != null; } catch (IOException e) { throw new UncheckedIOException(e); } } } @Override public Chunk<byte[], BytesReference> next() { if (nextData != null || hasNext()) { Chunk<byte[], BytesReference> data = nextData; nextData = null; return data; } else { throw new NoSuchElementException(); } } }; return StreamSupport.stream(Spliterators.spliteratorUnknownSize(iterator, Spliterator.ORDERED | Spliterator.NONNULL), false); }
[ "@", "Override", "public", "Stream", "<", "Chunk", "<", "byte", "[", "]", ",", "BytesReference", ">", ">", "chunks", "(", ")", "{", "Iterator", "<", "Chunk", "<", "byte", "[", "]", ",", "BytesReference", ">", ">", "iterator", "=", "new", "Iterator", ...
This methods creates a Java 8 stream of chunks. @return a stream of chunks
[ "This", "methods", "creates", "a", "Java", "8", "stream", "of", "chunks", "." ]
d8426fcfc686507cab59b3d8181b08f83718418c
https://github.com/xbib/marc/blob/d8426fcfc686507cab59b3d8181b08f83718418c/src/main/java/org/xbib/marc/io/BaseChunkStream.java#L74-L106
train
threerings/narya
core/src/main/java/com/threerings/presents/net/AESAuthRequest.java
AESAuthRequest.decrypt
public void decrypt (byte[] key) throws IOException, ClassNotFoundException { if (_clearCreds != null) { return; } _key = key; try { _contents = SecureUtil.getAESCipher(Cipher.DECRYPT_MODE, _key).doFinal(_contents); } catch (GeneralSecurityException gse) { IOException ioe = new IOException("Failed to decrypt credentials"); ioe.initCause(gse); throw ioe; } ByteArrayInputStream byteIn = new ByteArrayInputStream(_contents); ObjectInputStream cipherIn = new ObjectInputStream(byteIn); _clearCreds = (Credentials)cipherIn.readObject(); }
java
public void decrypt (byte[] key) throws IOException, ClassNotFoundException { if (_clearCreds != null) { return; } _key = key; try { _contents = SecureUtil.getAESCipher(Cipher.DECRYPT_MODE, _key).doFinal(_contents); } catch (GeneralSecurityException gse) { IOException ioe = new IOException("Failed to decrypt credentials"); ioe.initCause(gse); throw ioe; } ByteArrayInputStream byteIn = new ByteArrayInputStream(_contents); ObjectInputStream cipherIn = new ObjectInputStream(byteIn); _clearCreds = (Credentials)cipherIn.readObject(); }
[ "public", "void", "decrypt", "(", "byte", "[", "]", "key", ")", "throws", "IOException", ",", "ClassNotFoundException", "{", "if", "(", "_clearCreds", "!=", "null", ")", "{", "return", ";", "}", "_key", "=", "key", ";", "try", "{", "_contents", "=", "S...
Decrypts the request after transmission.
[ "Decrypts", "the", "request", "after", "transmission", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/net/AESAuthRequest.java#L106-L124
train
threerings/narya
core/src/main/java/com/threerings/presents/net/AESAuthRequest.java
AESAuthRequest.writeObject
public void writeObject (ObjectOutputStream out) throws IOException { out.defaultWriteObject(); ByteArrayOutputStream byteOut = new ByteArrayOutputStream(); ObjectOutputStream oOut = new ObjectOutputStream(byteOut); oOut.writeObject(_clearCreds); try { byte[] encrypted = SecureUtil.getAESCipher(Cipher.ENCRYPT_MODE, _key).doFinal(byteOut.toByteArray()); out.writeInt(encrypted.length); out.write(encrypted); } catch (GeneralSecurityException gse) { IOException ioe = new IOException("Failed to encrypt credentials"); ioe.initCause(gse); throw ioe; } }
java
public void writeObject (ObjectOutputStream out) throws IOException { out.defaultWriteObject(); ByteArrayOutputStream byteOut = new ByteArrayOutputStream(); ObjectOutputStream oOut = new ObjectOutputStream(byteOut); oOut.writeObject(_clearCreds); try { byte[] encrypted = SecureUtil.getAESCipher(Cipher.ENCRYPT_MODE, _key).doFinal(byteOut.toByteArray()); out.writeInt(encrypted.length); out.write(encrypted); } catch (GeneralSecurityException gse) { IOException ioe = new IOException("Failed to encrypt credentials"); ioe.initCause(gse); throw ioe; } }
[ "public", "void", "writeObject", "(", "ObjectOutputStream", "out", ")", "throws", "IOException", "{", "out", ".", "defaultWriteObject", "(", ")", ";", "ByteArrayOutputStream", "byteOut", "=", "new", "ByteArrayOutputStream", "(", ")", ";", "ObjectOutputStream", "oOut...
A customized AES encrypting write object.
[ "A", "customized", "AES", "encrypting", "write", "object", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/net/AESAuthRequest.java#L129-L146
train
threerings/narya
core/src/main/java/com/threerings/presents/net/AESAuthRequest.java
AESAuthRequest.readObject
@Override public void readObject (ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); _contents = new byte[in.readInt()]; in.read(_contents); }
java
@Override public void readObject (ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); _contents = new byte[in.readInt()]; in.read(_contents); }
[ "@", "Override", "public", "void", "readObject", "(", "ObjectInputStream", "in", ")", "throws", "IOException", ",", "ClassNotFoundException", "{", "in", ".", "defaultReadObject", "(", ")", ";", "_contents", "=", "new", "byte", "[", "in", ".", "readInt", "(", ...
Read in our encrypted contents.
[ "Read", "in", "our", "encrypted", "contents", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/net/AESAuthRequest.java#L151-L158
train
threerings/narya
core/src/main/java/com/threerings/presents/client/BlockingCommunicator.java
BlockingCommunicator.connectionFailed
protected synchronized void connectionFailed (final IOException ioe) { // make sure the socket isn't already closed down (meaning we've already dealt with the // failed connection) if (_channel == null) { return; } log.info("Connection failed", ioe); // let the client know that things went south notifyClientObservers(new ObserverOps.Client(_client) { @Override protected void notify (ClientObserver obs) { obs.clientConnectionFailed(_client, ioe); } }); // and request that we go through the motions of logging off logoff(); }
java
protected synchronized void connectionFailed (final IOException ioe) { // make sure the socket isn't already closed down (meaning we've already dealt with the // failed connection) if (_channel == null) { return; } log.info("Connection failed", ioe); // let the client know that things went south notifyClientObservers(new ObserverOps.Client(_client) { @Override protected void notify (ClientObserver obs) { obs.clientConnectionFailed(_client, ioe); } }); // and request that we go through the motions of logging off logoff(); }
[ "protected", "synchronized", "void", "connectionFailed", "(", "final", "IOException", "ioe", ")", "{", "// make sure the socket isn't already closed down (meaning we've already dealt with the", "// failed connection)", "if", "(", "_channel", "==", "null", ")", "{", "return", ...
Callback called by the reader or writer thread when something goes awry with our socket connection to the server.
[ "Callback", "called", "by", "the", "reader", "or", "writer", "thread", "when", "something", "goes", "awry", "with", "our", "socket", "connection", "to", "the", "server", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/client/BlockingCommunicator.java#L214-L233
train
threerings/narya
core/src/main/java/com/threerings/presents/client/BlockingCommunicator.java
BlockingCommunicator.readerDidExit
protected synchronized void readerDidExit () { // clear out our reader reference _reader = null; if (_writer == null) { // there's no writer during authentication, so we may be responsible for closing the // socket channel closeChannel(); // let the client know when we finally go away clientCleanup(_logonError); } log.debug("Reader thread exited."); }
java
protected synchronized void readerDidExit () { // clear out our reader reference _reader = null; if (_writer == null) { // there's no writer during authentication, so we may be responsible for closing the // socket channel closeChannel(); // let the client know when we finally go away clientCleanup(_logonError); } log.debug("Reader thread exited."); }
[ "protected", "synchronized", "void", "readerDidExit", "(", ")", "{", "// clear out our reader reference", "_reader", "=", "null", ";", "if", "(", "_writer", "==", "null", ")", "{", "// there's no writer during authentication, so we may be responsible for closing the", "// soc...
Callback called by the reader thread when it goes away.
[ "Callback", "called", "by", "the", "reader", "thread", "when", "it", "goes", "away", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/client/BlockingCommunicator.java#L254-L269
train
threerings/narya
core/src/main/java/com/threerings/presents/client/BlockingCommunicator.java
BlockingCommunicator.writerDidExit
protected synchronized void writerDidExit () { // clear out our writer reference _writer = null; log.debug("Writer thread exited."); // let the client observers know that we're logged off notifyClientObservers(new ObserverOps.Session(_client) { @Override protected void notify (SessionObserver obs) { obs.clientDidLogoff(_client); } }); // now that the writer thread has gone away, we can safely close our socket and let the // client know that the logoff process has completed closeChannel(); // let the client know when we finally go away if (_reader == null) { clientCleanup(_logonError); } }
java
protected synchronized void writerDidExit () { // clear out our writer reference _writer = null; log.debug("Writer thread exited."); // let the client observers know that we're logged off notifyClientObservers(new ObserverOps.Session(_client) { @Override protected void notify (SessionObserver obs) { obs.clientDidLogoff(_client); } }); // now that the writer thread has gone away, we can safely close our socket and let the // client know that the logoff process has completed closeChannel(); // let the client know when we finally go away if (_reader == null) { clientCleanup(_logonError); } }
[ "protected", "synchronized", "void", "writerDidExit", "(", ")", "{", "// clear out our writer reference", "_writer", "=", "null", ";", "log", ".", "debug", "(", "\"Writer thread exited.\"", ")", ";", "// let the client observers know that we're logged off", "notifyClientObser...
Callback called by the writer thread when it goes away.
[ "Callback", "called", "by", "the", "writer", "thread", "when", "it", "goes", "away", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/client/BlockingCommunicator.java#L274-L295
train
threerings/narya
core/src/main/java/com/threerings/presents/client/BlockingCommunicator.java
BlockingCommunicator.closeDatagramChannel
protected void closeDatagramChannel () { if (_selector != null) { try { _selector.close(); } catch (IOException ioe) { log.warning("Error closing selector: " + ioe); } _selector = null; } if (_datagramChannel != null) { log.debug("Closing datagram socket channel."); try { _datagramChannel.close(); } catch (IOException ioe) { log.warning("Error closing datagram socket: " + ioe); } _datagramChannel = null; // clear these out because they are probably large and in charge _uout = null; _sequencer = null; } }
java
protected void closeDatagramChannel () { if (_selector != null) { try { _selector.close(); } catch (IOException ioe) { log.warning("Error closing selector: " + ioe); } _selector = null; } if (_datagramChannel != null) { log.debug("Closing datagram socket channel."); try { _datagramChannel.close(); } catch (IOException ioe) { log.warning("Error closing datagram socket: " + ioe); } _datagramChannel = null; // clear these out because they are probably large and in charge _uout = null; _sequencer = null; } }
[ "protected", "void", "closeDatagramChannel", "(", ")", "{", "if", "(", "_selector", "!=", "null", ")", "{", "try", "{", "_selector", ".", "close", "(", ")", ";", "}", "catch", "(", "IOException", "ioe", ")", "{", "log", ".", "warning", "(", "\"Error cl...
Closes the datagram channel.
[ "Closes", "the", "datagram", "channel", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/client/BlockingCommunicator.java#L352-L376
train
threerings/narya
core/src/main/java/com/threerings/presents/client/BlockingCommunicator.java
BlockingCommunicator.sendMessage
protected void sendMessage (UpstreamMessage msg) throws IOException { if (debugLogMessages()) { log.info("SEND " + msg); } // first we write the message so that we can measure it's length _oout.writeObject(msg); _oout.flush(); // then write the framed message to actual output stream try { ByteBuffer buffer = _fout.frameAndReturnBuffer(); if (buffer.limit() > 4096) { String txt = StringUtil.truncate(String.valueOf(msg), 80, "..."); log.info("Whoa, writin' a big one", "msg", txt, "size", buffer.limit()); } int wrote = writeMessage(buffer); if (wrote != buffer.limit()) { log.warning("Aiya! Couldn't write entire message", "msg", msg, "size", buffer.limit(), "wrote", wrote); } else { // Log.info("Wrote " + wrote + " bytes."); _client.getMessageTracker().messageSent(false, wrote, msg); } } finally { _fout.resetFrame(); } // make a note of our most recent write time updateWriteStamp(); }
java
protected void sendMessage (UpstreamMessage msg) throws IOException { if (debugLogMessages()) { log.info("SEND " + msg); } // first we write the message so that we can measure it's length _oout.writeObject(msg); _oout.flush(); // then write the framed message to actual output stream try { ByteBuffer buffer = _fout.frameAndReturnBuffer(); if (buffer.limit() > 4096) { String txt = StringUtil.truncate(String.valueOf(msg), 80, "..."); log.info("Whoa, writin' a big one", "msg", txt, "size", buffer.limit()); } int wrote = writeMessage(buffer); if (wrote != buffer.limit()) { log.warning("Aiya! Couldn't write entire message", "msg", msg, "size", buffer.limit(), "wrote", wrote); } else { // Log.info("Wrote " + wrote + " bytes."); _client.getMessageTracker().messageSent(false, wrote, msg); } } finally { _fout.resetFrame(); } // make a note of our most recent write time updateWriteStamp(); }
[ "protected", "void", "sendMessage", "(", "UpstreamMessage", "msg", ")", "throws", "IOException", "{", "if", "(", "debugLogMessages", "(", ")", ")", "{", "log", ".", "info", "(", "\"SEND \"", "+", "msg", ")", ";", "}", "// first we write the message so that we ca...
Writes the supplied message to the socket.
[ "Writes", "the", "supplied", "message", "to", "the", "socket", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/client/BlockingCommunicator.java#L381-L414
train
threerings/narya
core/src/main/java/com/threerings/presents/client/BlockingCommunicator.java
BlockingCommunicator.sendDatagram
protected void sendDatagram (UpstreamMessage msg) throws IOException { // reset the stream and write our connection id and hash placeholder _bout.reset(); _uout.writeInt(_client.getConnectionId()); _uout.writeLong(0L); // write the datagram through the sequencer _sequencer.writeDatagram(msg); // flip the buffer and make sure it's not too long ByteBuffer buf = _bout.flip(); int size = buf.remaining(); if (size > Client.MAX_DATAGRAM_SIZE) { log.warning("Dropping oversized datagram", "size", size, "msg", msg); return; } // compute the hash buf.position(12); _digest.update(buf); byte[] hash = _digest.digest(_secret); // insert the first 64 bits of the hash buf.position(4); buf.put(hash, 0, 8).rewind(); // send the datagram writeDatagram(buf); // notify the tracker _client.getMessageTracker().messageSent(true, size, msg); }
java
protected void sendDatagram (UpstreamMessage msg) throws IOException { // reset the stream and write our connection id and hash placeholder _bout.reset(); _uout.writeInt(_client.getConnectionId()); _uout.writeLong(0L); // write the datagram through the sequencer _sequencer.writeDatagram(msg); // flip the buffer and make sure it's not too long ByteBuffer buf = _bout.flip(); int size = buf.remaining(); if (size > Client.MAX_DATAGRAM_SIZE) { log.warning("Dropping oversized datagram", "size", size, "msg", msg); return; } // compute the hash buf.position(12); _digest.update(buf); byte[] hash = _digest.digest(_secret); // insert the first 64 bits of the hash buf.position(4); buf.put(hash, 0, 8).rewind(); // send the datagram writeDatagram(buf); // notify the tracker _client.getMessageTracker().messageSent(true, size, msg); }
[ "protected", "void", "sendDatagram", "(", "UpstreamMessage", "msg", ")", "throws", "IOException", "{", "// reset the stream and write our connection id and hash placeholder", "_bout", ".", "reset", "(", ")", ";", "_uout", ".", "writeInt", "(", "_client", ".", "getConnec...
Sends a datagram over the datagram socket.
[ "Sends", "a", "datagram", "over", "the", "datagram", "socket", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/client/BlockingCommunicator.java#L430-L463
train
threerings/narya
core/src/main/java/com/threerings/presents/client/BlockingCommunicator.java
BlockingCommunicator.throttleOutgoingMessage
protected void throttleOutgoingMessage () { Throttle throttle = _client.getOutgoingMessageThrottle(); synchronized(throttle) { while (throttle.throttleOp()) { try { Thread.sleep(2); } catch (InterruptedException ie) { // no problem } } } }
java
protected void throttleOutgoingMessage () { Throttle throttle = _client.getOutgoingMessageThrottle(); synchronized(throttle) { while (throttle.throttleOp()) { try { Thread.sleep(2); } catch (InterruptedException ie) { // no problem } } } }
[ "protected", "void", "throttleOutgoingMessage", "(", ")", "{", "Throttle", "throttle", "=", "_client", ".", "getOutgoingMessageThrottle", "(", ")", ";", "synchronized", "(", "throttle", ")", "{", "while", "(", "throttle", ".", "throttleOp", "(", ")", ")", "{",...
Throttles an outgoing message operation in a thread-safe manner.
[ "Throttles", "an", "outgoing", "message", "operation", "in", "a", "thread", "-", "safe", "manner", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/client/BlockingCommunicator.java#L587-L599
train
xbib/marc
src/main/java/org/xbib/marc/transformer/field/MarcFieldTransformer.java
MarcFieldTransformer.interpolate
private String interpolate(MarcField marcField, String value) { if (value == null) { return null; } Matcher m = REP.matcher(value); if (m.find()) { return m.replaceAll(Integer.toString(repeatCounter)); } m = NREP.matcher(value); if (m.find()) { if (repeatCounter > 99) { repeatCounter = 99; logger.log(Level.WARNING, "counter > 99, overflow in %s", marcField); } return m.replaceAll(String.format("%02d", repeatCounter)); } return value; }
java
private String interpolate(MarcField marcField, String value) { if (value == null) { return null; } Matcher m = REP.matcher(value); if (m.find()) { return m.replaceAll(Integer.toString(repeatCounter)); } m = NREP.matcher(value); if (m.find()) { if (repeatCounter > 99) { repeatCounter = 99; logger.log(Level.WARNING, "counter > 99, overflow in %s", marcField); } return m.replaceAll(String.format("%02d", repeatCounter)); } return value; }
[ "private", "String", "interpolate", "(", "MarcField", "marcField", ",", "String", "value", ")", "{", "if", "(", "value", "==", "null", ")", "{", "return", "null", ";", "}", "Matcher", "m", "=", "REP", ".", "matcher", "(", "value", ")", ";", "if", "("...
Interpolate variables. @param marcField MARC field @param value the input value @return the interpolated string
[ "Interpolate", "variables", "." ]
d8426fcfc686507cab59b3d8181b08f83718418c
https://github.com/xbib/marc/blob/d8426fcfc686507cab59b3d8181b08f83718418c/src/main/java/org/xbib/marc/transformer/field/MarcFieldTransformer.java#L216-L233
train
threerings/narya
core/src/main/java/com/threerings/crowd/data/PlaceConfig.java
PlaceConfig.createController
public PlaceController createController () { Class<?> cclass = getControllerClass(); if (cclass == null) { throw new RuntimeException( "PlaceConfig.createController() must be overridden."); } log.warning("Providing backwards compatibility. PlaceConfig." + "createController() should be overridden directly."); try { return (PlaceController)cclass.newInstance(); } catch (Exception e) { log.warning("Failed to instantiate controller class '" + cclass + "'.", e); return null; } }
java
public PlaceController createController () { Class<?> cclass = getControllerClass(); if (cclass == null) { throw new RuntimeException( "PlaceConfig.createController() must be overridden."); } log.warning("Providing backwards compatibility. PlaceConfig." + "createController() should be overridden directly."); try { return (PlaceController)cclass.newInstance(); } catch (Exception e) { log.warning("Failed to instantiate controller class '" + cclass + "'.", e); return null; } }
[ "public", "PlaceController", "createController", "(", ")", "{", "Class", "<", "?", ">", "cclass", "=", "getControllerClass", "(", ")", ";", "if", "(", "cclass", "==", "null", ")", "{", "throw", "new", "RuntimeException", "(", "\"PlaceConfig.createController() mu...
Create the controller that should be used for this place.
[ "Create", "the", "controller", "that", "should", "be", "used", "for", "this", "place", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/crowd/data/PlaceConfig.java#L64-L80
train
threerings/narya
core/src/main/java/com/threerings/crowd/data/BodyObject.java
BodyObject.addWhoData
protected void addWhoData (StringBuilder buf) { buf.append(getOid()); if (status != OccupantInfo.ACTIVE) { buf.append(" ").append(getStatusTranslation()); } }
java
protected void addWhoData (StringBuilder buf) { buf.append(getOid()); if (status != OccupantInfo.ACTIVE) { buf.append(" ").append(getStatusTranslation()); } }
[ "protected", "void", "addWhoData", "(", "StringBuilder", "buf", ")", "{", "buf", ".", "append", "(", "getOid", "(", ")", ")", ";", "if", "(", "status", "!=", "OccupantInfo", ".", "ACTIVE", ")", "{", "buf", ".", "append", "(", "\" \"", ")", ".", "appe...
Allows derived classes to add data to the who details.
[ "Allows", "derived", "classes", "to", "add", "data", "to", "the", "who", "details", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/crowd/data/BodyObject.java#L217-L223
train
threerings/narya
core/src/main/java/com/threerings/presents/server/TimeBaseProvider.java
TimeBaseProvider.init
public static void init (InvocationManager invmgr, RootDObjectManager omgr) { // we'll need these later _invmgr = invmgr; _omgr = omgr; // register a provider instance invmgr.registerProvider(new TimeBaseProvider(), TimeBaseMarshaller.class, GLOBAL_GROUP); }
java
public static void init (InvocationManager invmgr, RootDObjectManager omgr) { // we'll need these later _invmgr = invmgr; _omgr = omgr; // register a provider instance invmgr.registerProvider(new TimeBaseProvider(), TimeBaseMarshaller.class, GLOBAL_GROUP); }
[ "public", "static", "void", "init", "(", "InvocationManager", "invmgr", ",", "RootDObjectManager", "omgr", ")", "{", "// we'll need these later", "_invmgr", "=", "invmgr", ";", "_omgr", "=", "omgr", ";", "// register a provider instance", "invmgr", ".", "registerProvi...
Registers the time provider with the appropriate managers. Called by the presents server at startup.
[ "Registers", "the", "time", "provider", "with", "the", "appropriate", "managers", ".", "Called", "by", "the", "presents", "server", "at", "startup", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/server/TimeBaseProvider.java#L47-L55
train
threerings/narya
core/src/main/java/com/threerings/presents/server/TimeBaseProvider.java
TimeBaseProvider.createTimeBase
public static TimeBaseObject createTimeBase (String timeBase) { TimeBaseObject object = _omgr.registerObject(new TimeBaseObject()); _timeBases.put(timeBase, object); return object; }
java
public static TimeBaseObject createTimeBase (String timeBase) { TimeBaseObject object = _omgr.registerObject(new TimeBaseObject()); _timeBases.put(timeBase, object); return object; }
[ "public", "static", "TimeBaseObject", "createTimeBase", "(", "String", "timeBase", ")", "{", "TimeBaseObject", "object", "=", "_omgr", ".", "registerObject", "(", "new", "TimeBaseObject", "(", ")", ")", ";", "_timeBases", ".", "put", "(", "timeBase", ",", "obj...
Creates a time base object which can subsequently be fetched by the client and used to send delta times. @param timeBase the name of the time base to create. @return the created and registered time base object.
[ "Creates", "a", "time", "base", "object", "which", "can", "subsequently", "be", "fetched", "by", "the", "client", "and", "used", "to", "send", "delta", "times", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/server/TimeBaseProvider.java#L65-L70
train
threerings/narya
core/src/main/java/com/threerings/presents/server/TimeBaseProvider.java
TimeBaseProvider.getTimeOid
public void getTimeOid (ClientObject source, String timeBase, TimeBaseService.GotTimeBaseListener listener) throws InvocationException { // look up the time base object in question TimeBaseObject time = getTimeBase(timeBase); if (time == null) { throw new InvocationException(NO_SUCH_TIME_BASE); } // and send the response listener.gotTimeOid(time.getOid()); }
java
public void getTimeOid (ClientObject source, String timeBase, TimeBaseService.GotTimeBaseListener listener) throws InvocationException { // look up the time base object in question TimeBaseObject time = getTimeBase(timeBase); if (time == null) { throw new InvocationException(NO_SUCH_TIME_BASE); } // and send the response listener.gotTimeOid(time.getOid()); }
[ "public", "void", "getTimeOid", "(", "ClientObject", "source", ",", "String", "timeBase", ",", "TimeBaseService", ".", "GotTimeBaseListener", "listener", ")", "throws", "InvocationException", "{", "// look up the time base object in question", "TimeBaseObject", "time", "=",...
Processes a request from a client to fetch the oid of the specified time object.
[ "Processes", "a", "request", "from", "a", "client", "to", "fetch", "the", "oid", "of", "the", "specified", "time", "object", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/server/TimeBaseProvider.java#L84-L95
train
threerings/narya
core/src/main/java/com/threerings/presents/peer/server/PeerManager.java
PeerManager.getNodeObjects
public Iterable<NodeObject> getNodeObjects () { return Iterables.filter( Iterables.concat(Collections.singleton(_nodeobj), Iterables.transform(_peers.values(), GET_NODE_OBJECT)), Predicates.notNull()); }
java
public Iterable<NodeObject> getNodeObjects () { return Iterables.filter( Iterables.concat(Collections.singleton(_nodeobj), Iterables.transform(_peers.values(), GET_NODE_OBJECT)), Predicates.notNull()); }
[ "public", "Iterable", "<", "NodeObject", ">", "getNodeObjects", "(", ")", "{", "return", "Iterables", ".", "filter", "(", "Iterables", ".", "concat", "(", "Collections", ".", "singleton", "(", "_nodeobj", ")", ",", "Iterables", ".", "transform", "(", "_peers...
Returns an iterable over our node object and that of our peers.
[ "Returns", "an", "iterable", "over", "our", "node", "object", "and", "that", "of", "our", "peers", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/peer/server/PeerManager.java#L256-L262
train
threerings/narya
core/src/main/java/com/threerings/presents/peer/server/PeerManager.java
PeerManager.locateClient
public ClientInfo locateClient (final Name key) { return lookupNodeDatum(new Function<NodeObject,ClientInfo>() { public ClientInfo apply (NodeObject nodeobj) { return nodeobj.clients.get(key); } }); }
java
public ClientInfo locateClient (final Name key) { return lookupNodeDatum(new Function<NodeObject,ClientInfo>() { public ClientInfo apply (NodeObject nodeobj) { return nodeobj.clients.get(key); } }); }
[ "public", "ClientInfo", "locateClient", "(", "final", "Name", "key", ")", "{", "return", "lookupNodeDatum", "(", "new", "Function", "<", "NodeObject", ",", "ClientInfo", ">", "(", ")", "{", "public", "ClientInfo", "apply", "(", "NodeObject", "nodeobj", ")", ...
Locates the client with the specified name. Returns null if the client is not logged onto any peer.
[ "Locates", "the", "client", "with", "the", "specified", "name", ".", "Returns", "null", "if", "the", "client", "is", "not", "logged", "onto", "any", "peer", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/peer/server/PeerManager.java#L416-L423
train
threerings/narya
core/src/main/java/com/threerings/presents/peer/server/PeerManager.java
PeerManager.invokeNodeAction
public void invokeNodeAction (final NodeAction action, final Runnable onDropped) { // if we're not on the dobjmgr thread, get there if (!_omgr.isDispatchThread()) { _omgr.postRunnable(new Runnable() { public void run () { invokeNodeAction(action, onDropped); } }); return; } // first serialize the action to make sure we can byte[] actionBytes = flattenAction(action); // invoke the action on our local server if appropriate boolean invoked = false; if (action.isApplicable(_nodeobj)) { invokeAction(null, actionBytes); invoked = true; } // now send it to any remote node that is also appropriate for (PeerNode peer : _peers.values()) { if (peer.nodeobj != null && action.isApplicable(peer.nodeobj)) { peer.nodeobj.peerService.invokeAction(actionBytes); invoked = true; } } // if we did not invoke the action on any node, call the onDropped handler if (!invoked && onDropped != null) { onDropped.run(); } if (invoked) { _stats.noteNodeActionInvoked(action); // stats! } }
java
public void invokeNodeAction (final NodeAction action, final Runnable onDropped) { // if we're not on the dobjmgr thread, get there if (!_omgr.isDispatchThread()) { _omgr.postRunnable(new Runnable() { public void run () { invokeNodeAction(action, onDropped); } }); return; } // first serialize the action to make sure we can byte[] actionBytes = flattenAction(action); // invoke the action on our local server if appropriate boolean invoked = false; if (action.isApplicable(_nodeobj)) { invokeAction(null, actionBytes); invoked = true; } // now send it to any remote node that is also appropriate for (PeerNode peer : _peers.values()) { if (peer.nodeobj != null && action.isApplicable(peer.nodeobj)) { peer.nodeobj.peerService.invokeAction(actionBytes); invoked = true; } } // if we did not invoke the action on any node, call the onDropped handler if (!invoked && onDropped != null) { onDropped.run(); } if (invoked) { _stats.noteNodeActionInvoked(action); // stats! } }
[ "public", "void", "invokeNodeAction", "(", "final", "NodeAction", "action", ",", "final", "Runnable", "onDropped", ")", "{", "// if we're not on the dobjmgr thread, get there", "if", "(", "!", "_omgr", ".", "isDispatchThread", "(", ")", ")", "{", "_omgr", ".", "po...
Invokes the supplied action on this and any other server that it indicates is appropriate. The action will be executed on the distributed object thread, but this method does not need to be called from the distributed object thread. @param onDropped a runnable to be executed if the action was not invoked on the local server or any peer node due to failing to match any of the nodes. The runnable will be executed on the dobj event thread.
[ "Invokes", "the", "supplied", "action", "on", "this", "and", "any", "other", "server", "that", "it", "indicates", "is", "appropriate", ".", "The", "action", "will", "be", "executed", "on", "the", "distributed", "object", "thread", "but", "this", "method", "d...
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/peer/server/PeerManager.java#L478-L516
train
threerings/narya
core/src/main/java/com/threerings/presents/peer/server/PeerManager.java
PeerManager.invokeNodeRequest
public <T> void invokeNodeRequest ( final NodeRequest request, final NodeRequestsListener<T> listener) { // if we're not on the dobjmgr thread, get there if (!_omgr.isDispatchThread()) { _omgr.postRunnable(new Runnable() { public void run () { invokeNodeRequest(request, listener); } }); return; } // serialize the action to make sure we can byte[] requestBytes = flattenRequest(request); // build a set of node names (including the local node) to which to send the request final Set<String> nodes = findApplicableNodes(request); if (nodes.isEmpty()) { listener.requestsProcessed(new NodeRequestsResultImpl<T>()); return; } final Map<String, T> results = Maps.newHashMap(); final Map<String, String> failures = Maps.newHashMap(); final AtomicInteger completedNodes = new AtomicInteger(); for (final String node : nodes) { invokeNodeRequest(node, requestBytes, new InvocationService.ResultListener() { public void requestProcessed (Object result) { // check off this node's successful response @SuppressWarnings("unchecked") T castResult = (T) result; results.put(node, castResult); nodeDone(); } public void requestFailed (String cause) { failures.put(node, cause); nodeDone(); } protected void nodeDone () { if (completedNodes.incrementAndGet() == nodes.size()) { // if all nodes have responded, let caller know listener.requestsProcessed(new NodeRequestsResultImpl<T>(results, failures)); } } }); } }
java
public <T> void invokeNodeRequest ( final NodeRequest request, final NodeRequestsListener<T> listener) { // if we're not on the dobjmgr thread, get there if (!_omgr.isDispatchThread()) { _omgr.postRunnable(new Runnable() { public void run () { invokeNodeRequest(request, listener); } }); return; } // serialize the action to make sure we can byte[] requestBytes = flattenRequest(request); // build a set of node names (including the local node) to which to send the request final Set<String> nodes = findApplicableNodes(request); if (nodes.isEmpty()) { listener.requestsProcessed(new NodeRequestsResultImpl<T>()); return; } final Map<String, T> results = Maps.newHashMap(); final Map<String, String> failures = Maps.newHashMap(); final AtomicInteger completedNodes = new AtomicInteger(); for (final String node : nodes) { invokeNodeRequest(node, requestBytes, new InvocationService.ResultListener() { public void requestProcessed (Object result) { // check off this node's successful response @SuppressWarnings("unchecked") T castResult = (T) result; results.put(node, castResult); nodeDone(); } public void requestFailed (String cause) { failures.put(node, cause); nodeDone(); } protected void nodeDone () { if (completedNodes.incrementAndGet() == nodes.size()) { // if all nodes have responded, let caller know listener.requestsProcessed(new NodeRequestsResultImpl<T>(results, failures)); } } }); } }
[ "public", "<", "T", ">", "void", "invokeNodeRequest", "(", "final", "NodeRequest", "request", ",", "final", "NodeRequestsListener", "<", "T", ">", "listener", ")", "{", "// if we're not on the dobjmgr thread, get there", "if", "(", "!", "_omgr", ".", "isDispatchThre...
Invokes the supplied request on all servers in parallel. The request will execute on the distributed object thread, but this method does not need to be called from there. If any one node reports failure, this function reports failure. If all nodes report success, this function will report success.
[ "Invokes", "the", "supplied", "request", "on", "all", "servers", "in", "parallel", ".", "The", "request", "will", "execute", "on", "the", "distributed", "object", "thread", "but", "this", "method", "does", "not", "need", "to", "be", "called", "from", "there"...
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/peer/server/PeerManager.java#L545-L592
train
threerings/narya
core/src/main/java/com/threerings/presents/peer/server/PeerManager.java
PeerManager.invokeNodeRequest
public void invokeNodeRequest (String nodeName, NodeRequest request, InvocationService.ResultListener listener) { invokeNodeRequest(nodeName, flattenRequest(request), listener); }
java
public void invokeNodeRequest (String nodeName, NodeRequest request, InvocationService.ResultListener listener) { invokeNodeRequest(nodeName, flattenRequest(request), listener); }
[ "public", "void", "invokeNodeRequest", "(", "String", "nodeName", ",", "NodeRequest", "request", ",", "InvocationService", ".", "ResultListener", "listener", ")", "{", "invokeNodeRequest", "(", "nodeName", ",", "flattenRequest", "(", "request", ")", ",", "listener",...
Invokes a node request on a specific node and returns the result through the listener.
[ "Invokes", "a", "node", "request", "on", "a", "specific", "node", "and", "returns", "the", "result", "through", "the", "listener", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/peer/server/PeerManager.java#L614-L618
train
threerings/narya
core/src/main/java/com/threerings/presents/peer/server/PeerManager.java
PeerManager.proxyRemoteObject
public <T extends DObject> void proxyRemoteObject ( String nodeName, final int remoteOid, final ResultListener<Integer> listener) { proxyRemoteObject(new DObjectAddress(nodeName, remoteOid), listener); }
java
public <T extends DObject> void proxyRemoteObject ( String nodeName, final int remoteOid, final ResultListener<Integer> listener) { proxyRemoteObject(new DObjectAddress(nodeName, remoteOid), listener); }
[ "public", "<", "T", "extends", "DObject", ">", "void", "proxyRemoteObject", "(", "String", "nodeName", ",", "final", "int", "remoteOid", ",", "final", "ResultListener", "<", "Integer", ">", "listener", ")", "{", "proxyRemoteObject", "(", "new", "DObjectAddress",...
Initiates a proxy on an object that is managed by the specified peer. The object will be proxied into this server's distributed object space and its local oid reported back to the supplied result listener. <p> Note that proxy requests <em>do not</em> stack like subscription requests. Only one entity must issue a request to proxy an object and that entity must be responsible for releasing the proxy when it knows that there are no longer any local subscribers to the object.
[ "Initiates", "a", "proxy", "on", "an", "object", "that", "is", "managed", "by", "the", "specified", "peer", ".", "The", "object", "will", "be", "proxied", "into", "this", "server", "s", "distributed", "object", "space", "and", "its", "local", "oid", "repor...
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/peer/server/PeerManager.java#L631-L635
train
threerings/narya
core/src/main/java/com/threerings/presents/peer/server/PeerManager.java
PeerManager.unproxyRemoteObject
public void unproxyRemoteObject (DObjectAddress addr) { Tuple<Subscriber<?>, DObject> bits = _proxies.remove(addr); if (bits == null) { log.warning("Requested to clear unknown proxy", "addr", addr); return; } // If it's local, just remove the subscriber we added and bail if (Objects.equal(addr.nodeName, _nodeName)) { bits.right.removeSubscriber(bits.left); return; } // clear out the local object manager's proxy mapping _omgr.clearProxyObject(addr.oid, bits.right); final Client peer = getPeerClient(addr.nodeName); if (peer == null) { log.warning("Unable to unsubscribe from proxy, missing peer", "addr", addr); return; } // restore the object's omgr reference to our ClientDObjectMgr and its oid back to the // remote oid so that it can properly finish the unsubscription process bits.right.setOid(addr.oid); bits.right.setManager(peer.getDObjectManager()); // finally unsubscribe from the object on our peer peer.getDObjectManager().unsubscribeFromObject(addr.oid, bits.left); }
java
public void unproxyRemoteObject (DObjectAddress addr) { Tuple<Subscriber<?>, DObject> bits = _proxies.remove(addr); if (bits == null) { log.warning("Requested to clear unknown proxy", "addr", addr); return; } // If it's local, just remove the subscriber we added and bail if (Objects.equal(addr.nodeName, _nodeName)) { bits.right.removeSubscriber(bits.left); return; } // clear out the local object manager's proxy mapping _omgr.clearProxyObject(addr.oid, bits.right); final Client peer = getPeerClient(addr.nodeName); if (peer == null) { log.warning("Unable to unsubscribe from proxy, missing peer", "addr", addr); return; } // restore the object's omgr reference to our ClientDObjectMgr and its oid back to the // remote oid so that it can properly finish the unsubscription process bits.right.setOid(addr.oid); bits.right.setManager(peer.getDObjectManager()); // finally unsubscribe from the object on our peer peer.getDObjectManager().unsubscribeFromObject(addr.oid, bits.left); }
[ "public", "void", "unproxyRemoteObject", "(", "DObjectAddress", "addr", ")", "{", "Tuple", "<", "Subscriber", "<", "?", ">", ",", "DObject", ">", "bits", "=", "_proxies", ".", "remove", "(", "addr", ")", ";", "if", "(", "bits", "==", "null", ")", "{", ...
Unsubscribes from and clears a proxied object. The caller must be sure that there are no remaining subscribers to the object on this local server.
[ "Unsubscribes", "from", "and", "clears", "a", "proxied", "object", ".", "The", "caller", "must", "be", "sure", "that", "there", "are", "no", "remaining", "subscribers", "to", "the", "object", "on", "this", "local", "server", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/peer/server/PeerManager.java#L698-L729
train
threerings/narya
core/src/main/java/com/threerings/presents/peer/server/PeerManager.java
PeerManager.getPeerPublicHostName
public String getPeerPublicHostName (String nodeName) { if (Objects.equal(_nodeName, nodeName)) { return _self.publicHostName; } PeerNode peer = _peers.get(nodeName); return (peer == null) ? null : peer.getPublicHostName(); }
java
public String getPeerPublicHostName (String nodeName) { if (Objects.equal(_nodeName, nodeName)) { return _self.publicHostName; } PeerNode peer = _peers.get(nodeName); return (peer == null) ? null : peer.getPublicHostName(); }
[ "public", "String", "getPeerPublicHostName", "(", "String", "nodeName", ")", "{", "if", "(", "Objects", ".", "equal", "(", "_nodeName", ",", "nodeName", ")", ")", "{", "return", "_self", ".", "publicHostName", ";", "}", "PeerNode", "peer", "=", "_peers", "...
Returns the public hostname to use when connecting to the specified peer or null if the peer is not currently connected to this server.
[ "Returns", "the", "public", "hostname", "to", "use", "when", "connecting", "to", "the", "specified", "peer", "or", "null", "if", "the", "peer", "is", "not", "currently", "connected", "to", "this", "server", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/peer/server/PeerManager.java#L758-L765
train
threerings/narya
core/src/main/java/com/threerings/presents/peer/server/PeerManager.java
PeerManager.getPeerInternalHostName
public String getPeerInternalHostName (String nodeName) { if (Objects.equal(_nodeName, nodeName)) { return _self.hostName; } PeerNode peer = _peers.get(nodeName); return (peer == null) ? null : peer.getInternalHostName(); }
java
public String getPeerInternalHostName (String nodeName) { if (Objects.equal(_nodeName, nodeName)) { return _self.hostName; } PeerNode peer = _peers.get(nodeName); return (peer == null) ? null : peer.getInternalHostName(); }
[ "public", "String", "getPeerInternalHostName", "(", "String", "nodeName", ")", "{", "if", "(", "Objects", ".", "equal", "(", "_nodeName", ",", "nodeName", ")", ")", "{", "return", "_self", ".", "hostName", ";", "}", "PeerNode", "peer", "=", "_peers", ".", ...
Returns the internal hostname to use when connecting to the specified peer or null if the peer is not currently connected to this server. Peers connect to one another via their internal hostname. Do not publish this data to clients out on the Internets.
[ "Returns", "the", "internal", "hostname", "to", "use", "when", "connecting", "to", "the", "specified", "peer", "or", "null", "if", "the", "peer", "is", "not", "currently", "connected", "to", "this", "server", ".", "Peers", "connect", "to", "one", "another", ...
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/peer/server/PeerManager.java#L772-L779
train
threerings/narya
core/src/main/java/com/threerings/presents/peer/server/PeerManager.java
PeerManager.getPeerPort
public int getPeerPort (String nodeName) { if (Objects.equal(_nodeName, nodeName)) { return _self.port; } PeerNode peer = _peers.get(nodeName); return (peer == null) ? -1 : peer.getPort(); }
java
public int getPeerPort (String nodeName) { if (Objects.equal(_nodeName, nodeName)) { return _self.port; } PeerNode peer = _peers.get(nodeName); return (peer == null) ? -1 : peer.getPort(); }
[ "public", "int", "getPeerPort", "(", "String", "nodeName", ")", "{", "if", "(", "Objects", ".", "equal", "(", "_nodeName", ",", "nodeName", ")", ")", "{", "return", "_self", ".", "port", ";", "}", "PeerNode", "peer", "=", "_peers", ".", "get", "(", "...
Returns the port on which to connect to the specified peer or -1 if the peer is not currently connected to this server.
[ "Returns", "the", "port", "on", "which", "to", "connect", "to", "the", "specified", "peer", "or", "-", "1", "if", "the", "peer", "is", "not", "currently", "connected", "to", "this", "server", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/peer/server/PeerManager.java#L785-L792
train
threerings/narya
core/src/main/java/com/threerings/presents/peer/server/PeerManager.java
PeerManager.acquireLock
public void acquireLock (final NodeObject.Lock lock, final ResultListener<String> listener) { // wait until any pending resolution is complete queryLock(lock, new ChainedResultListener<String, String>(listener) { public void requestCompleted (String result) { if (result == null) { if (_suboids.isEmpty()) { lockAcquired(lock, 0L, listener); } else { _locks.put(lock, new LockHandler(lock, true, listener)); } } else { listener.requestCompleted(result); } } }); }
java
public void acquireLock (final NodeObject.Lock lock, final ResultListener<String> listener) { // wait until any pending resolution is complete queryLock(lock, new ChainedResultListener<String, String>(listener) { public void requestCompleted (String result) { if (result == null) { if (_suboids.isEmpty()) { lockAcquired(lock, 0L, listener); } else { _locks.put(lock, new LockHandler(lock, true, listener)); } } else { listener.requestCompleted(result); } } }); }
[ "public", "void", "acquireLock", "(", "final", "NodeObject", ".", "Lock", "lock", ",", "final", "ResultListener", "<", "String", ">", "listener", ")", "{", "// wait until any pending resolution is complete", "queryLock", "(", "lock", ",", "new", "ChainedResultListener...
Acquires a lock on a resource shared amongst this node's peers. If the lock is successfully acquired, the supplied listener will receive this node's name. If another node acquires the lock first, then the listener will receive the name of that node.
[ "Acquires", "a", "lock", "on", "a", "resource", "shared", "amongst", "this", "node", "s", "peers", ".", "If", "the", "lock", "is", "successfully", "acquired", "the", "supplied", "listener", "will", "receive", "this", "node", "s", "name", ".", "If", "anothe...
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/peer/server/PeerManager.java#L799-L815
train
threerings/narya
core/src/main/java/com/threerings/presents/peer/server/PeerManager.java
PeerManager.queryLock
public void queryLock (NodeObject.Lock lock, ResultListener<String> listener) { // if it's being resolved, add the listener to the list LockHandler handler = _locks.get(lock); if (handler != null) { handler.listeners.add(listener); return; } // otherwise, return its present value listener.requestCompleted(queryLock(lock)); }
java
public void queryLock (NodeObject.Lock lock, ResultListener<String> listener) { // if it's being resolved, add the listener to the list LockHandler handler = _locks.get(lock); if (handler != null) { handler.listeners.add(listener); return; } // otherwise, return its present value listener.requestCompleted(queryLock(lock)); }
[ "public", "void", "queryLock", "(", "NodeObject", ".", "Lock", "lock", ",", "ResultListener", "<", "String", ">", "listener", ")", "{", "// if it's being resolved, add the listener to the list", "LockHandler", "handler", "=", "_locks", ".", "get", "(", "lock", ")", ...
Determines the owner of the specified lock, waiting for any resolution to complete before notifying the supplied listener.
[ "Determines", "the", "owner", "of", "the", "specified", "lock", "waiting", "for", "any", "resolution", "to", "complete", "before", "notifying", "the", "supplied", "listener", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/peer/server/PeerManager.java#L876-L887
train
threerings/narya
core/src/main/java/com/threerings/presents/peer/server/PeerManager.java
PeerManager.addStaleCacheObserver
public void addStaleCacheObserver (String cache, StaleCacheObserver observer) { ObserverList<StaleCacheObserver> list = _cacheobs.get(cache); if (list == null) { list = ObserverList.newFastUnsafe(); _cacheobs.put(cache, list); } list.add(observer); }
java
public void addStaleCacheObserver (String cache, StaleCacheObserver observer) { ObserverList<StaleCacheObserver> list = _cacheobs.get(cache); if (list == null) { list = ObserverList.newFastUnsafe(); _cacheobs.put(cache, list); } list.add(observer); }
[ "public", "void", "addStaleCacheObserver", "(", "String", "cache", ",", "StaleCacheObserver", "observer", ")", "{", "ObserverList", "<", "StaleCacheObserver", ">", "list", "=", "_cacheobs", ".", "get", "(", "cache", ")", ";", "if", "(", "list", "==", "null", ...
Registers a stale cache observer.
[ "Registers", "a", "stale", "cache", "observer", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/peer/server/PeerManager.java#L974-L982
train
threerings/narya
core/src/main/java/com/threerings/presents/peer/server/PeerManager.java
PeerManager.removeStaleCacheObserver
public void removeStaleCacheObserver (String cache, StaleCacheObserver observer) { ObserverList<StaleCacheObserver> list = _cacheobs.get(cache); if (list == null) { return; } list.remove(observer); if (list.isEmpty()) { _cacheobs.remove(cache); } }
java
public void removeStaleCacheObserver (String cache, StaleCacheObserver observer) { ObserverList<StaleCacheObserver> list = _cacheobs.get(cache); if (list == null) { return; } list.remove(observer); if (list.isEmpty()) { _cacheobs.remove(cache); } }
[ "public", "void", "removeStaleCacheObserver", "(", "String", "cache", ",", "StaleCacheObserver", "observer", ")", "{", "ObserverList", "<", "StaleCacheObserver", ">", "list", "=", "_cacheobs", ".", "get", "(", "cache", ")", ";", "if", "(", "list", "==", "null"...
Removes a stale cache observer registration.
[ "Removes", "a", "stale", "cache", "observer", "registration", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/peer/server/PeerManager.java#L987-L997
train
threerings/narya
core/src/main/java/com/threerings/presents/peer/server/PeerManager.java
PeerManager.broadcastStaleCacheData
public void broadcastStaleCacheData (String cache, Streamable data) { _nodeobj.setCacheData(new NodeObject.CacheData(cache, data)); }
java
public void broadcastStaleCacheData (String cache, Streamable data) { _nodeobj.setCacheData(new NodeObject.CacheData(cache, data)); }
[ "public", "void", "broadcastStaleCacheData", "(", "String", "cache", ",", "Streamable", "data", ")", "{", "_nodeobj", ".", "setCacheData", "(", "new", "NodeObject", ".", "CacheData", "(", "cache", ",", "data", ")", ")", ";", "}" ]
Called when cached data has changed on the local server and needs to inform our peers.
[ "Called", "when", "cached", "data", "has", "changed", "on", "the", "local", "server", "and", "needs", "to", "inform", "our", "peers", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/peer/server/PeerManager.java#L1002-L1005
train
threerings/narya
core/src/main/java/com/threerings/presents/peer/server/PeerManager.java
PeerManager.refreshPeer
protected void refreshPeer (NodeRecord record) { PeerNode peer = _peers.get(record.nodeName); if (peer == null) { peer = _injector.getInstance(getPeerNodeClass()); _peers.put(record.nodeName, peer); peer.init(record); } peer.refresh(record); }
java
protected void refreshPeer (NodeRecord record) { PeerNode peer = _peers.get(record.nodeName); if (peer == null) { peer = _injector.getInstance(getPeerNodeClass()); _peers.put(record.nodeName, peer); peer.init(record); } peer.refresh(record); }
[ "protected", "void", "refreshPeer", "(", "NodeRecord", "record", ")", "{", "PeerNode", "peer", "=", "_peers", ".", "get", "(", "record", ".", "nodeName", ")", ";", "if", "(", "peer", "==", "null", ")", "{", "peer", "=", "_injector", ".", "getInstance", ...
Ensures that we have a connection to the specified node if it has checked in since we last failed to connect.
[ "Ensures", "that", "we", "have", "a", "connection", "to", "the", "specified", "node", "if", "it", "has", "checked", "in", "since", "we", "last", "failed", "to", "connect", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/peer/server/PeerManager.java#L1224-L1233
train
threerings/narya
core/src/main/java/com/threerings/presents/peer/server/PeerManager.java
PeerManager.changedCacheData
protected void changedCacheData (String cache, final Streamable data) { // see if we have any observers ObserverList<StaleCacheObserver> list = _cacheobs.get(cache); if (list == null) { return; } // if so, notify them list.apply(new ObserverList.ObserverOp<StaleCacheObserver>() { public boolean apply (StaleCacheObserver observer) { observer.changedCacheData(data); return true; } }); }
java
protected void changedCacheData (String cache, final Streamable data) { // see if we have any observers ObserverList<StaleCacheObserver> list = _cacheobs.get(cache); if (list == null) { return; } // if so, notify them list.apply(new ObserverList.ObserverOp<StaleCacheObserver>() { public boolean apply (StaleCacheObserver observer) { observer.changedCacheData(data); return true; } }); }
[ "protected", "void", "changedCacheData", "(", "String", "cache", ",", "final", "Streamable", "data", ")", "{", "// see if we have any observers", "ObserverList", "<", "StaleCacheObserver", ">", "list", "=", "_cacheobs", ".", "get", "(", "cache", ")", ";", "if", ...
Called when possibly cached data has changed on one of our peer servers.
[ "Called", "when", "possibly", "cached", "data", "has", "changed", "on", "one", "of", "our", "peer", "servers", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/peer/server/PeerManager.java#L1283-L1297
train
threerings/narya
core/src/main/java/com/threerings/presents/peer/server/PeerManager.java
PeerManager.droppedLock
protected void droppedLock (final NodeObject.Lock lock) { _nodeobj.removeFromLocks(lock); _stats.locksHijacked++; _dropobs.apply(new ObserverList.ObserverOp<DroppedLockObserver>() { public boolean apply (DroppedLockObserver observer) { observer.droppedLock(lock); return true; } }); }
java
protected void droppedLock (final NodeObject.Lock lock) { _nodeobj.removeFromLocks(lock); _stats.locksHijacked++; _dropobs.apply(new ObserverList.ObserverOp<DroppedLockObserver>() { public boolean apply (DroppedLockObserver observer) { observer.droppedLock(lock); return true; } }); }
[ "protected", "void", "droppedLock", "(", "final", "NodeObject", ".", "Lock", "lock", ")", "{", "_nodeobj", ".", "removeFromLocks", "(", "lock", ")", ";", "_stats", ".", "locksHijacked", "++", ";", "_dropobs", ".", "apply", "(", "new", "ObserverList", ".", ...
Called when we have been forced to drop a lock.
[ "Called", "when", "we", "have", "been", "forced", "to", "drop", "a", "lock", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/peer/server/PeerManager.java#L1302-L1312
train
threerings/narya
core/src/main/java/com/threerings/presents/peer/server/PeerManager.java
PeerManager.clientLoggedOn
protected void clientLoggedOn (String nodeName, ClientInfo clinfo) { PresentsSession session = _clmgr.getClient(clinfo.username); if (session != null) { log.info("Booting user that has connected on another node", "username", clinfo.username, "otherNode", nodeName); session.endSession(); } }
java
protected void clientLoggedOn (String nodeName, ClientInfo clinfo) { PresentsSession session = _clmgr.getClient(clinfo.username); if (session != null) { log.info("Booting user that has connected on another node", "username", clinfo.username, "otherNode", nodeName); session.endSession(); } }
[ "protected", "void", "clientLoggedOn", "(", "String", "nodeName", ",", "ClientInfo", "clinfo", ")", "{", "PresentsSession", "session", "=", "_clmgr", ".", "getClient", "(", "clinfo", ".", "username", ")", ";", "if", "(", "session", "!=", "null", ")", "{", ...
Called when we hear about a client logging on to another node.
[ "Called", "when", "we", "hear", "about", "a", "client", "logging", "on", "to", "another", "node", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/peer/server/PeerManager.java#L1357-L1365
train
threerings/narya
core/src/main/java/com/threerings/presents/peer/server/PeerManager.java
PeerManager.peerAcquiringLock
protected void peerAcquiringLock (PeerNode peer, NodeObject.Lock lock) { // refuse to ratify if we believe someone else owns the lock String owner = queryLock(lock); if (owner != null) { log.warning("Refusing to ratify lock acquisition.", "lock", lock, "node", peer.getNodeName(), "owner", owner); return; } // check for an existing handler LockHandler handler = _locks.get(lock); if (handler == null) { createLockHandler(peer, lock, true); return; } // if the existing node has priority, we're done if (hasPriority(handler.getNodeName(), peer.getNodeName())) { return; } // the new node has priority, so cancel the existing handler and take over // its listeners ResultListenerList<String> olisteners = handler.listeners; handler.cancel(); handler = createLockHandler(peer, lock, true); handler.listeners = olisteners; }
java
protected void peerAcquiringLock (PeerNode peer, NodeObject.Lock lock) { // refuse to ratify if we believe someone else owns the lock String owner = queryLock(lock); if (owner != null) { log.warning("Refusing to ratify lock acquisition.", "lock", lock, "node", peer.getNodeName(), "owner", owner); return; } // check for an existing handler LockHandler handler = _locks.get(lock); if (handler == null) { createLockHandler(peer, lock, true); return; } // if the existing node has priority, we're done if (hasPriority(handler.getNodeName(), peer.getNodeName())) { return; } // the new node has priority, so cancel the existing handler and take over // its listeners ResultListenerList<String> olisteners = handler.listeners; handler.cancel(); handler = createLockHandler(peer, lock, true); handler.listeners = olisteners; }
[ "protected", "void", "peerAcquiringLock", "(", "PeerNode", "peer", ",", "NodeObject", ".", "Lock", "lock", ")", "{", "// refuse to ratify if we believe someone else owns the lock", "String", "owner", "=", "queryLock", "(", "lock", ")", ";", "if", "(", "owner", "!=",...
Called when a peer announces its intention to acquire a lock.
[ "Called", "when", "a", "peer", "announces", "its", "intention", "to", "acquire", "a", "lock", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/peer/server/PeerManager.java#L1414-L1442
train
threerings/narya
core/src/main/java/com/threerings/presents/peer/server/PeerManager.java
PeerManager.peerReleasingLock
protected void peerReleasingLock (PeerNode peer, NodeObject.Lock lock) { // refuse to ratify if we don't believe they own the lock String owner = queryLock(lock); if (!peer.getNodeName().equals(owner)) { log.warning("Refusing to ratify lock release.", "lock", lock, "node", peer.getNodeName(), "owner", owner); return; } // check for an existing handler LockHandler handler = _locks.get(lock); if (handler == null) { createLockHandler(peer, lock, false); } else { log.warning("Received request to release resolving lock", "node", peer.getNodeName(), "handler", handler); } }
java
protected void peerReleasingLock (PeerNode peer, NodeObject.Lock lock) { // refuse to ratify if we don't believe they own the lock String owner = queryLock(lock); if (!peer.getNodeName().equals(owner)) { log.warning("Refusing to ratify lock release.", "lock", lock, "node", peer.getNodeName(), "owner", owner); return; } // check for an existing handler LockHandler handler = _locks.get(lock); if (handler == null) { createLockHandler(peer, lock, false); } else { log.warning("Received request to release resolving lock", "node", peer.getNodeName(), "handler", handler); } }
[ "protected", "void", "peerReleasingLock", "(", "PeerNode", "peer", ",", "NodeObject", ".", "Lock", "lock", ")", "{", "// refuse to ratify if we don't believe they own the lock", "String", "owner", "=", "queryLock", "(", "lock", ")", ";", "if", "(", "!", "peer", "....
Called when a peer announces its intention to release a lock.
[ "Called", "when", "a", "peer", "announces", "its", "intention", "to", "release", "a", "lock", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/peer/server/PeerManager.java#L1447-L1465
train
threerings/narya
core/src/main/java/com/threerings/presents/peer/server/PeerManager.java
PeerManager.peerAddedLock
protected void peerAddedLock (String nodeName, NodeObject.Lock lock) { // check for hijacking if (_nodeobj.locks.contains(lock)) { log.warning("Client hijacked lock owned by this node", "lock", lock, "node", nodeName); droppedLock(lock); } // notify the handler, if any LockHandler handler = _locks.get(lock); if (handler != null) { handler.peerAddedLock(nodeName); } }
java
protected void peerAddedLock (String nodeName, NodeObject.Lock lock) { // check for hijacking if (_nodeobj.locks.contains(lock)) { log.warning("Client hijacked lock owned by this node", "lock", lock, "node", nodeName); droppedLock(lock); } // notify the handler, if any LockHandler handler = _locks.get(lock); if (handler != null) { handler.peerAddedLock(nodeName); } }
[ "protected", "void", "peerAddedLock", "(", "String", "nodeName", ",", "NodeObject", ".", "Lock", "lock", ")", "{", "// check for hijacking", "if", "(", "_nodeobj", ".", "locks", ".", "contains", "(", "lock", ")", ")", "{", "log", ".", "warning", "(", "\"Cl...
Called when a peer adds a lock.
[ "Called", "when", "a", "peer", "adds", "a", "lock", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/peer/server/PeerManager.java#L1470-L1483
train
threerings/narya
core/src/main/java/com/threerings/presents/peer/server/PeerManager.java
PeerManager.peerUpdatedLock
protected void peerUpdatedLock (String nodeName, NodeObject.Lock lock) { // notify the handler, if any LockHandler handler = _locks.get(lock); if (handler != null) { handler.peerUpdatedLock(nodeName); } }
java
protected void peerUpdatedLock (String nodeName, NodeObject.Lock lock) { // notify the handler, if any LockHandler handler = _locks.get(lock); if (handler != null) { handler.peerUpdatedLock(nodeName); } }
[ "protected", "void", "peerUpdatedLock", "(", "String", "nodeName", ",", "NodeObject", ".", "Lock", "lock", ")", "{", "// notify the handler, if any", "LockHandler", "handler", "=", "_locks", ".", "get", "(", "lock", ")", ";", "if", "(", "handler", "!=", "null"...
Called when a peer updates a lock.
[ "Called", "when", "a", "peer", "updates", "a", "lock", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/peer/server/PeerManager.java#L1488-L1495
train
threerings/narya
core/src/main/java/com/threerings/presents/peer/server/PeerManager.java
PeerManager.flattenAction
protected byte[] flattenAction (NodeAction action) { try { ByteArrayOutputStream bout = new ByteArrayOutputStream(); ObjectOutputStream oout = new ObjectOutputStream(bout); oout.writeObject(action); return bout.toByteArray(); } catch (Exception e) { throw new IllegalArgumentException( "Failed to serialize node action [action=" + action + "].", e); } }
java
protected byte[] flattenAction (NodeAction action) { try { ByteArrayOutputStream bout = new ByteArrayOutputStream(); ObjectOutputStream oout = new ObjectOutputStream(bout); oout.writeObject(action); return bout.toByteArray(); } catch (Exception e) { throw new IllegalArgumentException( "Failed to serialize node action [action=" + action + "].", e); } }
[ "protected", "byte", "[", "]", "flattenAction", "(", "NodeAction", "action", ")", "{", "try", "{", "ByteArrayOutputStream", "bout", "=", "new", "ByteArrayOutputStream", "(", ")", ";", "ObjectOutputStream", "oout", "=", "new", "ObjectOutputStream", "(", "bout", "...
Flattens the supplied node action into bytes.
[ "Flattens", "the", "supplied", "node", "action", "into", "bytes", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/peer/server/PeerManager.java#L1512-L1523
train
threerings/narya
core/src/main/java/com/threerings/presents/peer/server/PeerManager.java
PeerManager.flattenRequest
protected byte[] flattenRequest (NodeRequest request) { try { ByteArrayOutputStream bout = new ByteArrayOutputStream(); ObjectOutputStream oout = new ObjectOutputStream(bout); oout.writeObject(request); return bout.toByteArray(); } catch (Exception e) { throw new IllegalArgumentException( "Failed to serialize node request [request=" + request + "].", e); } }
java
protected byte[] flattenRequest (NodeRequest request) { try { ByteArrayOutputStream bout = new ByteArrayOutputStream(); ObjectOutputStream oout = new ObjectOutputStream(bout); oout.writeObject(request); return bout.toByteArray(); } catch (Exception e) { throw new IllegalArgumentException( "Failed to serialize node request [request=" + request + "].", e); } }
[ "protected", "byte", "[", "]", "flattenRequest", "(", "NodeRequest", "request", ")", "{", "try", "{", "ByteArrayOutputStream", "bout", "=", "new", "ByteArrayOutputStream", "(", ")", ";", "ObjectOutputStream", "oout", "=", "new", "ObjectOutputStream", "(", "bout", ...
Flattens the supplied node request into bytes.
[ "Flattens", "the", "supplied", "node", "request", "into", "bytes", "." ]
5b01edc8850ed0c32d004b4049e1ac4a02027ede
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/peer/server/PeerManager.java#L1528-L1539
train
dkpro/dkpro-argumentation
dkpro-argumentation-types/src/main/java/org/dkpro/argumentation/types/ArgumentUnitUtils.java
ArgumentUnitUtils.propertiesToString
protected static String propertiesToString(Properties properties) { StringWriter stringWriter = new StringWriter(); String comments = Properties.class.getName(); try { properties.store(stringWriter, comments); } catch (IOException e) { throw new RuntimeException(e); } stringWriter.flush(); String result = stringWriter.toString(); // let's get rid of the timestamp from the properties as it cannot be disabled // in the Properties implementation List<String> lines = new ArrayList<>(Arrays.asList(result.split("\n"))); // Remove the second line lines.remove(1); // join back result = StringUtils.join(lines, "\n"); return result; }
java
protected static String propertiesToString(Properties properties) { StringWriter stringWriter = new StringWriter(); String comments = Properties.class.getName(); try { properties.store(stringWriter, comments); } catch (IOException e) { throw new RuntimeException(e); } stringWriter.flush(); String result = stringWriter.toString(); // let's get rid of the timestamp from the properties as it cannot be disabled // in the Properties implementation List<String> lines = new ArrayList<>(Arrays.asList(result.split("\n"))); // Remove the second line lines.remove(1); // join back result = StringUtils.join(lines, "\n"); return result; }
[ "protected", "static", "String", "propertiesToString", "(", "Properties", "properties", ")", "{", "StringWriter", "stringWriter", "=", "new", "StringWriter", "(", ")", ";", "String", "comments", "=", "Properties", ".", "class", ".", "getName", "(", ")", ";", "...
Serializes properties to String @param properties properties @return string
[ "Serializes", "properties", "to", "String" ]
57ce6f5e73d8075b7088aeeebb107c85b3d4bbcb
https://github.com/dkpro/dkpro-argumentation/blob/57ce6f5e73d8075b7088aeeebb107c85b3d4bbcb/dkpro-argumentation-types/src/main/java/org/dkpro/argumentation/types/ArgumentUnitUtils.java#L79-L103
train