/** * Create a new allocation data. */ public AllocationData(int open, boolean retry, Object user) { this.open = open; this.retry = retry; this.user = user; this.result = new IntermediateFuture(); }
/** * Test if result value can be passed by reference. */ public IIntermediateFuture<Object> testResultReferences(Object[] args) { return new IntermediateFuture<Object>(Arrays.asList(args)); }
/** * Test if result value can be passed by copy. */ public IIntermediateFuture<Object> testResultCopies(Object[] args) { return new IntermediateFuture<Object>(Arrays.asList(args)); }
/** * Get all locally stored information about a person. * @param name The person's name. * @return Future that contains the information. */ public IIntermediateFuture<InformationEntry> getInformation(final String name) { return new IntermediateFuture<InformationEntry>(agent.getInformation(name)); }
/** * Example implementation of the method. */ public IIntermediateFuture<String> getIntermediateResults() { IntermediateFuture<String> ret = new IntermediateFuture<String>(); ret.addIntermediateResult("hello"); System.out.println("called method getIntermediateResults()"); return ret; }
/** * Start the distributor. */ public IIntermediateFuture<Object> init(Method method, Object[] args, IFilter<Tuple2<IService, Object[]>> filter, IParameterConverter conv) { this.method = method; this.args = args; this.filter = filter==null? new ConstantFilter<Tuple2<IService, Object[]>>(true): filter; this.conv = conv; results = new IntermediateFuture<Object>(); return results; }
/** * Start the distributor. */ public IIntermediateFuture<Object> init(Method method, Object[] args, IFilter<Tuple2<IService, Object[]>> filter, IParameterConverter conv) { this.method = method; this.args = args; this.filter = filter==null? new ConstantFilter<Tuple2<IService, Object[]>>(true): filter; this.conv = conv; results = new IntermediateFuture<Object>(); return results; }
/** * Get a snapshot of the currently managed file transfers. */ public IIntermediateFuture<TransferInfo> getFileTransfers() { List<TransferInfo> ret = new ArrayList<TransferInfo>(); for(Tuple3<TransferInfo, TerminableIntermediateFuture<Long>, IInputConnection> tup: transfers.values()) { ret.add(tup.getFirstEntity()); } for(Tuple3<TransferInfo, ITerminableFuture<IOutputConnection>, IConnection> tup: transfers2.values()) { ret.add(tup.getFirstEntity()); } return new IntermediateFuture<TransferInfo>(ret); }
/** * Execute the command. * @param lrms The local remote management service. * @return An optional result command that will be * sent back to the command origin. */ public IIntermediateFuture<IRemoteCommand> execute(IMicroExternalAccess component, RemoteServiceManagementService rsms) { final IntermediateFuture<IRemoteCommand> ret = new IntermediateFuture<IRemoteCommand>(); // RMS acts as representative of remote caller. IComponentIdentifier.LOCAL.set(caller); invokeMethod(ret, rsms); IComponentIdentifier.LOCAL.set(component.getComponentIdentifier()); return ret; }
/** * Get a snapshot of the currently managed file transfers. */ public IIntermediateFuture<TransferInfo> getFileTransfers() { List<TransferInfo> ret = new ArrayList<TransferInfo>(); for(Tuple3<TransferInfo, TerminableIntermediateFuture<Long>, IInputConnection> tup: transfers.values()) { ret.add(tup.getFirstEntity()); } for(Tuple3<TransferInfo, ITerminableFuture<IOutputConnection>, IConnection> tup: transfers2.values()) { ret.add(tup.getFirstEntity()); } return new IntermediateFuture<TransferInfo>(ret); }
/** * Get a snapshot of the currently managed file transfers. */ public IIntermediateFuture<TransferInfo> getFileTransfers() { List<TransferInfo> ret = new ArrayList<TransferInfo>(); for(Tuple3<TransferInfo, TerminableIntermediateFuture<Long>, IInputConnection> tup: transfers.values()) { ret.add(tup.getFirstEntity()); } for(Tuple3<TransferInfo, ITerminableFuture<IOutputConnection>, IConnection> tup: transfers2.values()) { ret.add(tup.getFirstEntity()); } return new IntermediateFuture<TransferInfo>(ret); }
/** * Test method for @CheckState with intermediate results. * * Will automatically try to determine the number of intermediate results to keep. */ public IIntermediateFuture<Integer> getIncreasingValue() { final IntermediateFuture<Integer> ret = new IntermediateFuture<Integer>(); ret.addIntermediateResult(Integer.valueOf(1)); ret.addIntermediateResult(Integer.valueOf(2)); ret.addIntermediateResult(Integer.valueOf(3)); ret.addIntermediateResult(Integer.valueOf(4)); ret.addIntermediateResult(Integer.valueOf(0)); return ret; }
/** * Be informed when one of the other methods futures is terminated. * Returns an initial result when this future is registered. * Is finished, when the terminate action of the other future was called. */ public IIntermediateFuture<Void> terminateCalled() { IntermediateFuture<Void> ret = new IntermediateFuture<Void>(); if(termfut!=null) { ret.setException(new RuntimeException("Must not be called twice before result is available")); } else { ret.addIntermediateResult(null); termfut = ret; } return ret; } }
@Classname("checkExistence") public IIntermediateFuture<FileData> execute(IInternalAccess ia) { IntermediateFuture<FileData> ret = new IntermediateFuture<FileData>(); for(int i=0; i<files.length; i++) { try { File f = new File(files[i]); if(f.exists()) { ret.addIntermediateResult(new FileData(new File(files[i]).getAbsoluteFile())); } } catch(Exception e) { // Protect remote platform from execution errors. System.err.println("File: "+files[i]); Thread.dumpStack(); e.printStackTrace(); } } return ret; } });
/** * Fetch emails for a subscription. * @param sub The subscription. * @return The emails. */ public IIntermediateFuture<Email> fetchEmails(SubscriptionInfo sub) { List<Email> emails = sub.getNewEmails(); // Hack, needed because pool cannot be used (pro) agent.getComponentFeature(IExecutionFeature.class).scheduleStep(new IComponentStep<Void>() { public IFuture<Void> execute(IInternalAccess ia) { // System.out.println("kill: "+agent); agent.killComponent(); return IFuture.DONE; } }); return new IntermediateFuture<Email>(emails); } }
/** * Get all declared services of the given provider. * @return The corresponding services. */ public static IIntermediateFuture<IService> getDeclaredServices(IServiceProvider provider) { // synchronized(profiling) // { // Integer cnt = (Integer)profiling.get(type); // profiling.put(type, Integer.valueOf(cnt!=null ? cnt.intValue()+1 : 1)); // } final IntermediateFuture<IService> ret = new IntermediateFuture<IService>(); // Hack->remove // IVisitDecider contdecider = new DefaultVisitDecider(false); // if(Proxy.isProxyClass(provider.getClass())) // System.out.println("herere"); provider.getServices(getSearchManager(false, RequiredServiceInfo.SCOPE_LOCAL), contdecider, contanyselector) .addResultListener(new IntermediateDelegationResultListener<IService>(ret)); return ret; }
@Classname("convertPathToRelative") public IIntermediateFuture<String> execute(IInternalAccess ia) { IntermediateFuture<String> ret = new IntermediateFuture<String>(); try { for(String path: paths) { ret.addIntermediateResult(SUtil.convertPathToRelative(path)); } ret.setFinished(); } catch(Exception e) { // Protect remote platform from execution errors. Thread.dumpStack(); e.printStackTrace(); ret.setException(e); } return ret; } });
/** * Execute the command. * @param lrms The local remote management service. * @return An optional result command that will be * sent back to the command origin. */ public IIntermediateFuture<IRemoteCommand> execute(IExternalAccess component, RemoteServiceManagementService rsms) { final IntermediateFuture<IRemoteCommand> ret = new IntermediateFuture<IRemoteCommand>(); try { rsms.getRemoteReferenceModule().addRemoteReference(rr, holder); ret.addIntermediateResult(new RemoteResultCommand(null, null, null, callid, false, null, getNonFunctionalProperties())); ret.setFinished(); // ret.setResult(new RemoteResultCommand(null, null, callid, false)); } catch(Exception e) { e.printStackTrace(); ret.setException(e); } return ret; }
/** * Test local. */ protected IIntermediateFuture<TestReport> testLocal(final int testno) { final IntermediateFuture<TestReport> ret = new IntermediateFuture<TestReport>(); performTests(agent.getComponentIdentifier().getRoot(), testno, true) .addResultListener(agent.getComponentFeature(IExecutionFeature.class).createResultListener(new IntermediateDelegationResultListener<TestReport>(ret))); return ret; }
/** * Get a file filter according to current file type settings. */ protected IIntermediateFuture<FileData> listFiles() { final IntermediateFuture<FileData> ret = new IntermediateFuture<FileData>(); if(file instanceof RemoteJarFile) { RemoteJarFile myfile = (RemoteJarFile)file; Collection<FileData> files = myfile.listFiles(); ret.setResult(files); } else { SRemoteGui.listFiles(file, factory.getFileFilter(), exta) .addResultListener(new IntermediateDelegationResultListener<FileData>(ret)); } return ret; }