public void register() throws DTFException { String id = Action.getLocalID(); Connect connect; connect = new Connect(id); /* * Put default Attribs into connect message. */ Iterator objs = _attribs.values().iterator(); while (objs.hasNext()) { Attrib attrib = (Attrib) objs.next(); connect.addAttrib(attrib); } connect.setAddress(_server.getAddress()); connect.setPort(_server.getPort()); connect.setBuildid(DTFNode.getBuildID()); if (_logger.isDebugEnabled()) { _logger.debug("Registering " + connect); } try { _node.register(connect).execute(); } catch (RemoteException e) { convertException(e, "Unable to register."); } }
public void stop() throws RecorderException { try { _recorder.stop(); TxtQuery query = new TxtQuery(); query.open(_uri, null, null, null, null, DTFConstants.DEFAULT_ENCODING); Cursor cursor = new Cursor(query); int count = 0; if (DTFNode.getOwner() != null) { String ownerId = DTFNode.getOwner().getOwner(); Sequence seq = new Sequence(); seq.setThreadID(_threadId); while (true) { HashMap<String, String> map = cursor.next(false); if (map == null) break; Event event = CLIUtil.hashMapToEvent(map); seq.addAction(event); count++; if (count > 100) { Action.getComm().sendAction(ownerId, seq); seq.clearChildren(); count = 0; } } if (seq.children().size() != 0) Action.getComm().sendAction(ownerId, seq); } } catch (StorageException e) { throw new RecorderException("Error handling remote events.", e); } catch (DTFException e) { throw new RecorderException("Error handling remote events.", e); } finally { try { RemoteStorage.delete(_uri); } catch (StorageException e) { throw new RecorderException("Error cleaning up event file.", e); } } }
public RemoteRecorder(Action action, boolean append, String threadId) throws RecorderException { super(null, append, DTFConstants.DEFAULT_ENCODING); _threadId = threadId; try { RemoteStorage.init(); _uri = RemoteStorage.createUniqueURI("events-", ".txt"); _recorder = new TextRecorder(_uri, append, DTFConstants.DEFAULT_ENCODING); if (Action.getLogger().isDebugEnabled()) Action.getLogger().debug("Created file " + _uri); } catch (StorageException e) { throw new RecorderException("Unable to open remote storage.", e); } catch (URISyntaxException e) { throw new RecorderException("Unable to open remote storage.", e); } catch (ParseException e) { throw new RecorderException("Unable to open remote storage.", e); } }
public void unregister(DTFState state) throws DTFException { String id = Action.getLocalID(); if (id == null) return; Connect connect; connect = new Connect(id); /* * Put default Attribs into connect message. */ Iterator objs = _attribs.values().iterator(); while (objs.hasNext()) { Attrib attrib = (Attrib) objs.next(); connect.addAttrib(attrib); } try { _node.unregister(connect).execute(); } catch (RemoteException e) { convertException(e, "Unable to register node."); } }