/** * Flush any instrumentation for the given class in the remote system and clean up the local cache. * * @throws Exception in case of failure. */ public void removeAllInstrumentation() throws Exception { submit.deleteScripts(installedScripts); removeLocalState(); }
/** * Deletes rules from Byteman, where the rule definitions are found in the * given streams. Rule definitions are read from the streams so that details * of which rules to unload can be uploaded directly to the Byteman agent. * * This method is useful for using rules files from the classpath. * * @param resourceStreams * the URLS to files containing the rule definitions to be deleted * from Byteman * * @return the results of the deletion * * @throws Exception * if the request failed */ public String deleteRulesFromResources(List<InputStream> resourceStreams) throws Exception { List<ScriptText> scripts = getRulesFromRuleStreams(resourceStreams); return deleteScripts(scripts); }
/** * Deletes rules from Byteman, where the rule definitions are found in the * local files found at the given paths. After this method is done, the * given rules will no longer be processed by Byteman. The rule definitions * found in the files are actually passed down directly to Byteman, not the * file paths themselves. Therefore, these files must exist on the machine * where this client is running (i.e. the files are not read directly by the * Byteman agent). * * @param filePaths * the local files containing the rule definitions to be deleted * from Byteman * * @return the results of the deletion * * @throws Exception * if the request failed */ public String deleteRulesFromFiles(List<String> filePaths) throws Exception { List<ScriptText> scripts = getRulesFromRuleFiles(filePaths); return deleteScripts(scripts); }
/** * <p> * Removing particular script from the remote byteman agent. * <p> * If you submitted a rule directly to remote JVM then the scriptName * is the name under the script was installed. * <p> * If you used {@link #setRedirectedSubmissionsFile(File)} to define * a file where the rule will be written then this method won't work * and you will get an {@link IllegalStateException}. * * @param scriptName name of script that should be removed * @throws Exception in case that script can't be removed */ public void removeScript(String scriptName) throws Exception { ScriptText script = findInstalledScript(scriptName); if(script == null) { throw new IllegalStateException("Script name " + scriptName + " can't be removed as " + "was not found in list of installed scripts"); } submit.deleteScripts(Arrays.asList(script)); installedScripts.remove(script); }
/** * unloads a script previously supplied as a text String * @param clazz the test class * @param testName the test name * @throws Exception if the script text cannot be unloaded */ public static void unloadScriptText(Class<?> clazz, String testName) throws Exception { String className = clazz.getName(); if (testName == null) { testName = ""; } String key = className + "+" + testName; String scriptText = fileTable.remove(key); if (scriptText == null) { throw new Exception("Rule script not found " + key); } Submit submit = new Submit(getHost(), getPort()); if (isBMUnitVerbose()) { System.out.println("BMUnit : unloading text script = " + key); } List<ScriptText> scripts = new ArrayList<ScriptText>(); ScriptText script = new ScriptText(key, scriptText); scripts.add(script); submit.deleteScripts(scripts); }