code stringlengths 73 34.1k | label stringclasses 1
value |
|---|---|
public void setClassLoader (ClassLoader loader)
{
_loader = loader;
PresentsConnection conn = getConnection();
if (conn != null) {
conn.setClassLoader(loader);
}
} | java |
@EventThread
public void endSession ()
{
_clmgr.clientSessionWillEnd(this);
// queue up a request for our connection to be closed (if we have a connection, that is)
Connection conn = getConnection();
if (conn != null) {
// go ahead and clear out our connection now to... | java |
public void handleMessage (Message message)
{
// if the client has been getting crazy with the cheeze whiz, stick a fork in them; the
// first time through we end our session, subsequently _throttle is null and we just drop
// any messages that come in until we've fully shutdown
if (... | java |
protected void dispatchMessage (Message message)
{
_messagesIn++; // count 'em up!
// we dispatch to a message dispatcher that is specialized for the particular class of
// message that we received
MessageDispatcher disp = _disps.get(message.getClass());
if (disp == null) {
... | java |
protected void startSession (Name authname, AuthRequest req, PresentsConnection conn,
Object authdata)
{
_authname = authname;
_areq = req;
_authdata = authdata;
setConnection(conn);
// resolve our client object before we get fully underway
_clmgr.resolveClie... | java |
protected void resumeSession (AuthRequest req, PresentsConnection conn)
{
// check to see if we've already got a connection object, in which case it's probably stale
Connection oldconn = getConnection();
if (oldconn != null && !oldconn.isClosed()) {
log.info("Closing stale connec... | java |
@EventThread
protected void finishResumeSession ()
{
// if we have no client object for whatever reason; we're hosed, shut ourselves down
if (_clobj == null) {
log.info("Missing client object for resuming session " + this + ".");
endSession();
return;
... | java |
@AnyThread
protected void safeEndSession ()
{
if (!_omgr.isRunning()) {
log.info("Dropping end session request as we're shutting down " + this + ".");
} else {
_omgr.postRunnable(new Runnable() {
public void run () {
endSession();
... | java |
protected synchronized void unmapSubscrip (int oid)
{
ClientProxy rec;
synchronized (_subscrips) {
rec = _subscrips.remove(oid);
}
if (rec != null) {
rec.unsubscribe();
} else {
boolean alreadyDestroyed = _destroyedSubs.remove(oid);
... | java |
protected void clearSubscrips (boolean verbose)
{
for (ClientProxy rec : _subscrips.values()) {
if (verbose) {
log.info("Clearing subscription", "client", this, "obj", rec.object.getOid());
}
rec.unsubscribe();
}
_subscrips.clear();
} | java |
protected void sendBootstrap ()
{
// log.info("Sending bootstrap " + this + ".");
// create and populate our bootstrap data
BootstrapData data = createBootstrapData();
populateBootstrapData(data);
// create a send bootstrap notification
postMessage(new BootstrapNoti... | java |
protected synchronized void setConnection (PresentsConnection conn)
{
long now = System.currentTimeMillis();
if (_conn != null) {
// if our connection is being cleared out, record the amount of time we were connected
// to our total connected time
if (conn == null... | java |
protected void finishCompoundMessage ()
{
if (--_compoundDepth == 0) {
CompoundDownstreamMessage downstream = _compound;
_compound = null;
if (!downstream.msgs.isEmpty()) {
postMessage(downstream, null);
}
}
} | java |
protected boolean postMessage (DownstreamMessage msg, PresentsConnection expect)
{
PresentsConnection conn = getConnection();
// make sure that the connection they expect us to be using is the one we're using; there
// are circumstances were sufficient delay between request and response giv... | java |
protected void throttleUpdated ()
{
int messagesPerSec;
synchronized(_pendingThrottles) {
if (_pendingThrottles.size() == 0) {
log.warning("Received throttleUpdated but have no pending throttles",
"client", this);
return;
... | java |
public V get (long timeout, TimeUnit unit)
throws InterruptedException, ExecutionException, TimeoutException
{
return _sync.innerGet(unit.toNanos(timeout));
} | java |
public void requestProcessed (Object result)
{
@SuppressWarnings("unchecked") V value = (V)result;
_sync.innerSet(value);
} | java |
protected DSetEditor<E> createEditor (
DObject setter, String setName, Class<?> entryClass, String[] editableFields,
ObjectEditorTable.FieldInterpreter interp, EntryGrouper<E> grouper, String group)
{
return new DSetEditor<E>(setter, setName, entryClass, editableFields,
inter... | java |
public String getPeerHostName (String region)
{
return (ALWAYS_CONNECT_INTERNAL || Objects.equal(this.region, region))
? hostName
: publicHostName;
} | java |
public void setClassLoader (ClassLoader loader)
{
_loader = loader;
if (_comm != null) {
_comm.setClassLoader(loader);
}
} | java |
public void registerFlushDelay (Class<?> objclass, long delay)
{
ClientDObjectMgr omgr = (ClientDObjectMgr)getDObjectManager();
omgr.registerFlushDelay(objclass, delay);
} | java |
public synchronized boolean logon ()
{
// if we have a communicator reference, we're already logged on
if (_comm != null) {
return false;
}
// notify our observers immediately
_observers.apply(new ObserverOps.Session(this) {
@Override protected void n... | java |
public boolean logoff (boolean abortable)
{
// if we have no communicator, we're not logged on anyway
if (_comm == null) {
log.warning("Ignoring request to logoff because we're not logged on.");
return true;
}
// if the request is abortable, let's run it past... | java |
public String[] prepareStandaloneLogon ()
{
_standalone = true;
// notify our observers immediately
_observers.apply(new ObserverOps.Session(this) {
@Override protected void notify (SessionObserver obs) {
obs.clientWillLogon(_client);
}
});
... | java |
public void standaloneLogon (BootstrapData data, DObjectManager omgr)
{
if (!_standalone) {
throw new IllegalStateException("Must call prepareStandaloneLogon() first.");
}
gotBootstrap(data, omgr);
} | java |
public void standaloneLogoff ()
{
notifyObservers(new ObserverOps.Session(this) {
@Override protected void notify (SessionObserver obs) {
obs.clientDidLogoff(_client);
}
});
cleanup(null); // this will set _standalone to false
} | java |
protected synchronized void setOutgoingMessageThrottle (int msgsPerSec)
{
log.info("Updating outgoing message throttle", "msgsPerSec", msgsPerSec);
_outThrottle.reinit(msgsPerSec, 1000L);
_comm.postMessage(new ThrottleUpdatedMessage());
} | java |
protected void tick ()
{
// if we're not connected, skip it
if (_comm == null) {
return;
}
long now = RunAnywhere.currentTimeMillis();
if (_dcalc != null) {
// if our current calculator is done, clear it out
if (_dcalc.isDone()) {
... | java |
protected void gotClientObject (ClientObject clobj)
{
// keep this around
_clobj = clobj;
// let the client know that logon has now fully succeeded
notifyObservers(new ObserverOps.Session(this) {
@Override protected void notify (SessionObserver obs) {
obs... | java |
protected void getClientObjectFailed (final Exception cause)
{
// pass the buck onto the listeners
notifyObservers(new ObserverOps.Client(this) {
@Override protected void notify (ClientObserver obs) {
obs.clientFailedToLogon(_client, cause);
}
});
... | java |
protected void clientObjectDidChange (ClientObject clobj)
{
_clobj = clobj;
_cloid = _clobj.getOid();
// report to our observers
notifyObservers(new ObserverOps.Session(this) {
@Override protected void notify (SessionObserver obs) {
obs.clientObjectDidCha... | java |
public Deque<Subfield> getSubfield(String subfieldId) {
return subfields.stream()
.filter(subfield -> subfield.getId().equals(subfieldId))
.collect(Collectors.toCollection(LinkedList::new));
} | java |
public MarcField matchValue(Pattern pattern) {
if (value != null && pattern.matcher(value).matches()) {
return this;
}
for (Subfield subfield : subfields) {
if (pattern.matcher(subfield.getValue()).matches()) {
return this;
}
}
... | java |
public String toTagIndicatorKey() {
return (tag == null ? EMPTY_STRING : tag) + KEY_DELIMITER + (indicator == null ? EMPTY_STRING : indicator);
} | java |
public String toKey() {
return (tag == null ? EMPTY_STRING : tag) + KEY_DELIMITER + (indicator == null ? EMPTY_STRING : indicator) +
KEY_DELIMITER + subfieldIds;
} | java |
public void updateOccupantStatus (BodyObject body, final byte status)
{
// no need to NOOP
if (body.status != status) {
// update the status in their body object
body.setStatus(status);
body.getLocal(BodyLocal.class).statusTime = System.currentTimeMillis();
... | java |
public void setIdle (ClientObject caller, boolean idle)
{
BodyObject bobj = _locator.forClient(caller);
// determine the body's proposed new status
byte nstatus = (idle) ? OccupantInfo.IDLE : OccupantInfo.ACTIVE;
if (bobj == null || bobj.status == nstatus) {
return; // i... | java |
public Stats getStats (boolean snapshot)
{
synchronized (this) {
if (snapshot) {
_recent = _current;
_current = new Stats();
_current.maxQueueSize = _queue.size();
}
return _recent;
}
} | java |
public final void requestProcessed (Object result)
{
@SuppressWarnings("unchecked") T casted = (T)result;
requestCompleted(casted);
} | java |
public void requestFailed (Exception cause)
{
if (_chain != null) {
_chain.requestFailed(cause);
} else if (_invChain != null) {
_invChain.requestFailed((cause instanceof InvocationException)
? cause.getMessage()
: InvocationCodes.INTERNAL_ERR... | java |
public void requestCompleted (T result)
{
if (_chain != null) {
_chain.requestCompleted(result);
} else if (_invChain instanceof InvocationService.ResultListener) {
((InvocationService.ResultListener)_invChain).requestProcessed(result);
} else if (_invChain instance... | java |
public void init (CrowdContext ctx, PlaceConfig config)
{
// keep these around
_ctx = ctx;
_config = config;
// create our user interface
_view = createPlaceView(_ctx);
// initialize our delegates
applyToDelegates(new DelegateOp(PlaceControllerDelegate.class... | java |
protected void addDelegate (PlaceControllerDelegate delegate)
{
if (_delegates == null) {
_delegates = Lists.newArrayList();
}
_delegates.add(delegate);
} | java |
public void gotConfigInfo (String[] keys, int[] oids)
{
_csubscribers = new ConfigObjectSubscriber[keys.length];
for (int ii = 0; ii < keys.length; ii++) {
_csubscribers[ii] = new ConfigObjectSubscriber();
_csubscribers[ii].subscribeConfig(keys[ii], oids[ii]);
}
} | java |
public List<MarcField> getFields(String tag) {
return marcFields.stream().filter(marcField -> marcField.getTag().equals(tag))
.collect(Collectors.toList());
} | java |
public List<MarcField> filterKey(Pattern pattern) {
return marcFields.stream()
.map(field -> field.matchKey(pattern))
.filter(Objects::nonNull)
.collect(Collectors.toList());
} | java |
public List<MarcField> filterValue(Pattern pattern) {
return marcFields.stream().map(field ->
field.matchValue(pattern)).filter(Objects::nonNull).collect(Collectors.toList());
} | java |
public static SessionFactory newSessionFactory (
final Class<? extends Credentials> credsClass,
final Class<? extends PresentsSession> sessionClass,
final Class<? extends Name> nameClass,
final Class<? extends ClientResolver> resolverClass)
{
return new SessionFactory() {
... | java |
public void init (DObjectManager omgr, final int cloid, Client client)
{
// sanity check
if (_clobj != null) {
log.warning("Zoiks, client object around during invmgr init!");
cleanup();
}
// keep these for later
_omgr = omgr;
_client = client;... | java |
public void registerReceiver (InvocationDecoder decoder)
{
// add the receiver to the list
_reclist.add(decoder);
// if we're already online, assign a receiver id to this decoder
if (_clobj != null) {
assignReceiverId(decoder);
}
} | java |
public void unregisterReceiver (String receiverCode)
{
// remove the receiver from the list
for (Iterator<InvocationDecoder> iter = _reclist.iterator(); iter.hasNext(); ) {
InvocationDecoder decoder = iter.next();
if (decoder.getReceiverCode().equals(receiverCode)) {
... | java |
protected void assignReceiverIds ()
{
// pack all the events into a single transaction
_clobj.startTransaction();
try {
// clear out our previous registrations
_clobj.setReceivers(new DSet<Registration>());
for (InvocationDecoder decoder : _reclist) {
... | java |
public void eventReceived (DEvent event)
{
if (event instanceof InvocationResponseEvent) {
InvocationResponseEvent ire = (InvocationResponseEvent)event;
handleInvocationResponse(ire.getRequestId(), ire.getMethodId(), ire.getArgs());
} else if (event instanceof InvocationNoti... | java |
protected void handleInvocationResponse (int reqId, int methodId, Object[] args)
{
// look up the invocation marshaller registered for that response
ListenerMarshaller listener = _listeners.remove(reqId);
if (listener == null) {
log.warning("Received invocation response for which... | java |
protected void handleInvocationNotification (int receiverId, int methodId, Object[] args)
{
// look up the decoder registered for this receiver
InvocationDecoder decoder = _receivers.get(receiverId);
if (decoder == null) {
log.warning("Received notification for which we have no r... | java |
protected void handleClientObjectChanged (int newCloid)
{
// subscribe to the new client object
_omgr.subscribeToObject(newCloid, new Subscriber<ClientObject>() {
public void objectAvailable (ClientObject clobj) {
// grab a reference to our old receiver registrations
... | java |
public PlaceManager createPlace (PlaceConfig config)
throws InstantiationException, InvocationException
{
return createPlace(config, null, null);
} | java |
public PlaceManager createPlace (PlaceConfig config, List<PlaceManagerDelegate> delegates)
throws InstantiationException, InvocationException
{
return createPlace(config, delegates, null);
} | java |
public Iterator<PlaceObject> enumeratePlaces ()
{
final Iterator<PlaceManager> itr = _pmgrs.values().iterator();
return new Iterator<PlaceObject>() {
public boolean hasNext () {
return itr.hasNext();
}
public PlaceObject next () {
P... | java |
protected PlaceManager createPlace (PlaceConfig config, List<PlaceManagerDelegate> delegates,
PreStartupHook hook)
throws InstantiationException, InvocationException
{
PlaceManager pmgr = null;
try {
// create a place manager using the cla... | java |
protected void unmapPlaceManager (PlaceManager pmgr)
{
int ploid = pmgr.getPlaceObject().getOid();
// remove it from the table
if (_pmgrs.remove(ploid) == null) {
log.warning("Requested to unmap unmapped place manager", "pmgr", pmgr);
// } else {
// Log.info(... | java |
public synchronized static boolean isStreamable (Class<?> target)
{
// if we have not yet initialized ourselves, do so now
maybeInit();
// if we already have a streamer, or it's an enum, it's good
if (_streamers.containsKey(target) || target.isEnum()) {
return true;
... | java |
public static Class<?> getStreamerClass (Object object)
{
return (object instanceof Enum<?>) ?
((Enum<?>)object).getDeclaringClass() : object.getClass();
} | java |
public static Class<?> getCollectionClass (Class<?> clazz)
{
if (Streamable.class.isAssignableFrom(clazz)) {
// the class is natively streamable, let's ignore it
return null;
}
for (Class<?> collClass : BasicStreamers.CollectionStreamer.SPECIFICITY_ORDER) {
... | java |
protected static Streamer create (Class<?> target)
throws IOException
{
// validate that the class is really streamable
boolean isInner = false, isStatic = Modifier.isStatic(target.getModifiers());
try {
isInner = (target.getDeclaringClass() != null);
} catch (Thr... | java |
public void applyToOccupants (OccupantOp op)
{
if (_plobj != null) {
for (OccupantInfo info : _plobj.occupantInfo) {
op.apply(info);
}
}
} | java |
public void init (PlaceRegistry registry, InvocationManager invmgr, RootDObjectManager omgr,
BodyLocator locator, PlaceConfig config)
{
_registry = registry;
_invmgr = invmgr;
_omgr = omgr;
_locator = locator;
_config = config;
// initialize our... | java |
public void addDelegate (PlaceManagerDelegate delegate)
{
if (_delegates == null) {
_delegates = Lists.newArrayList();
}
if (_omgr != null) {
delegate.init(this, _omgr, _invmgr);
delegate.didInit(_config);
}
_delegates.add(delegate);
} | java |
public void applyToDelegates (DelegateOp op)
{
if (_delegates != null) {
for (int ii = 0, ll = _delegates.size(); ii < ll; ii++) {
PlaceManagerDelegate delegate = _delegates.get(ii);
if (op.shouldApply(delegate)) {
op.apply(delegate);
... | java |
public void startup (PlaceObject plobj)
{
// keep track of this
_plobj = plobj;
// we usually want to create and register a speaker service instance that clients can use
// to speak in this place
if (shouldCreateSpeakService()) {
plobj.setSpeakService(addProvider... | java |
@Deprecated
public void registerMessageHandler (String name, MessageHandler handler)
{
// create our handler map if necessary
if (_msghandlers == null) {
_msghandlers = Maps.newHashMap();
}
_msghandlers.put(name, handler);
} | java |
public void messageReceived (MessageEvent event)
{
if (_msghandlers != null) {
MessageHandler handler = _msghandlers.get(event.getName());
if (handler != null) {
handler.handleEvent(event, this);
}
}
// If the message is directed at us, se... | java |
protected <T extends InvocationMarshaller<?>> T addProvider (
InvocationProvider prov, Class<T> mclass)
{
T marsh = _invmgr.registerProvider(prov, mclass);
_marshallers.add(marsh);
return marsh;
} | java |
protected <T extends InvocationMarshaller<?>> T addDispatcher (InvocationDispatcher<T> disp)
{
T marsh = _invmgr.registerDispatcher(disp);
_marshallers.add(marsh);
return marsh;
} | java |
protected void bodyEntered (final int bodyOid)
{
log.debug("Body entered", "where", where(), "oid", bodyOid);
// let our delegates know what's up
applyToDelegates(new DelegateOp(PlaceManagerDelegate.class) {
@Override
public void apply (PlaceManagerDelegate delegate)... | java |
protected void bodyLeft (final int bodyOid)
{
log.debug("Body left", "where", where(), "oid", bodyOid);
// if their occupant info hasn't been removed (which may be the case if they logged off
// rather than left via a MoveTo request), we need to get it on out of here
Integer key = I... | java |
protected void bodyUpdated (final OccupantInfo info)
{
// let our delegates know what's up
applyToDelegates(new DelegateOp(PlaceManagerDelegate.class) {
@Override
public void apply (PlaceManagerDelegate delegate) {
delegate.bodyUpdated(info);
}
... | java |
protected void placeBecameEmpty ()
{
// let our delegates know what's up
applyToDelegates(new DelegateOp(PlaceManagerDelegate.class) {
@Override
public void apply (PlaceManagerDelegate delegate) {
delegate.placeBecameEmpty();
}
});
// ... | java |
protected void checkShutdownInterval ()
{
// queue up a shutdown interval, unless we've already got one.
long idlePeriod = idleUnloadPeriod();
if (idlePeriod > 0L && _shutdownInterval == null) {
(_shutdownInterval = _omgr.newInterval(new Runnable() {
public void r... | java |
public static void sendInfo (DObject speakObj, String bundle, String message)
{
sendSystem(speakObj, bundle, message, SystemMessage.INFO);
} | java |
public static void sendFeedback (DObject speakObj, String bundle, String message)
{
sendSystem(speakObj, bundle, message, SystemMessage.FEEDBACK);
} | java |
public static void sendAttention (DObject speakObj, String bundle, String message)
{
sendSystem(speakObj, bundle, message, SystemMessage.ATTENTION);
} | java |
public static void sendMessage (DObject speakObj, ChatMessage msg)
{
if (speakObj == null) {
log.warning("Dropping speak message, no speak obj '" + msg + "'.", new Exception());
return;
}
// post the message to the relevant object
speakObj.postMessage(ChatCod... | java |
protected static void sendSystem (DObject speakObj, String bundle, String message, byte level)
{
sendMessage(speakObj, new SystemMessage(message, bundle, level));
} | java |
public static Twilight getTwilight(double sunDistanceRadians) {
double altDegrees = 90.0 - Math.toDegrees(sunDistanceRadians);
if (altDegrees >= 0.0) {
return Twilight.DAYLIGHT;
} else if (altDegrees >= -6.0) {
return Twilight.CIVIL;
} else if (altDegrees >= -12.0) {
return Twilight.NAUTICAL;
} else... | java |
public static Position getSubSolarPoint(Calendar time) {
// convert time to Julian Day Number
double jd = TimeUtil.getJulianDayNumber(time);
// Julian centuries since Jan 1, 2000, 12:00 UTC
double T = (jd - 2451545.0) / 36525;
// mean anomaly, degree
double M = 357.52910 + 35999.05030 * T - 0.0001559 * ... | java |
public void elementUpdated (ElementUpdatedEvent event)
{
dispatchMethod(event.getName() + "Updated",
new Object[] { event.getIndex(), event.getValue() });
} | java |
public void dispatchMethod (String name, Object[] arguments)
{
// first check the cache
Method method = _mcache.get(name);
if (method == null) {
// if we haven't already determined this method doesn't exist, try
// to resolve it
if (!_mcache.containsKey(na... | java |
protected Method resolveMethod (String name, Object[] arguments)
{
Class<?>[] ptypes = new Class<?>[arguments.length];
for (int ii = 0; ii < arguments.length; ii++) {
ptypes[ii] = arguments[ii] == null ?
null : arguments[ii].getClass();
}
try {
... | java |
public static Transport getInstance (Type type, int channel)
{
// were there more parameters in transport objects, it would be better to have a single map
// of instances and use Transport objects as keys (as in examples of the flyweight
// pattern). however, doing it this way avoids the ne... | java |
public Transport combine (Transport other)
{
// if the channels are different, we fall back to the default channel
return getInstance(
_type.combine(other._type),
(_channel == other._channel) ? _channel : 0);
} | java |
public void broadcast (Name from, String bundle, String msg, boolean attention, boolean forward)
{
byte levelOrMode = (from != null) ? ChatCodes.BROADCAST_MODE
: (attention ? SystemMessage.ATTENTION : SystemMessage.INFO);
broadcast(from, levelOrMode, bundle, msg, forward);
} | java |
public void broadcast (Name from, byte levelOrMode, String bundle, String msg, boolean forward)
{
if (_broadcastObject != null) {
broadcastTo(_broadcastObject, from, levelOrMode, bundle, msg);
} else {
for (Iterator<PlaceObject> iter = _plreg.enumeratePlaces(); iter.hasNext(... | java |
public void deliverTell (UserMessage message, Name target, TellListener listener)
throws InvocationException
{
// make sure the target user is online
BodyObject tobj = _locator.lookupBody(target);
if (tobj == null) {
// if we have a forwarder configured, try forwarding th... | java |
public void deliverTell (BodyObject target, UserMessage message)
{
SpeakUtil.sendMessage(target, message);
// note that the teller "heard" what they said
SpeakUtil.noteMessage(target, message.speaker, message);
} | java |
protected void broadcastTo (
DObject object, Name from, byte levelOrMode, String bundle, String msg)
{
if (from == null) {
SpeakUtil.sendSystem(object, bundle, msg, levelOrMode /* level */);
} else {
SpeakUtil.sendSpeak(object, from, bundle, msg, levelOrMode /* mode ... | java |
public void appendReport (StringBuilder report, long now, long sinceLast, boolean reset)
{
PresentsConMgrStats stats = getStats();
long eventCount = stats.eventCount - _lastStats.eventCount;
int connects = stats.connects - _lastStats.connects;
int disconnects = stats.disconnects - _l... | java |
public boolean setPrivateKey (PrivateKey key)
{
if (SecureUtil.ciphersSupported(key)) {
_privateKey = key;
return true;
}
return false;
} | java |
protected int handleDatagram (DatagramChannel listener, long when)
{
InetSocketAddress source;
_databuf.clear();
try {
source = (InetSocketAddress)listener.receive(_databuf);
} catch (IOException ioe) {
log.warning("Failure receiving datagram.", ioe);
... | java |
public void openOutgoingConnection (Connection conn, String hostname, int port)
throws IOException
{
// create a socket channel to use for this connection, initialize it and queue it up to
// have the non-blocking connect process started
SocketChannel sockchan = SocketChannel.open();... | java |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.