public List<InetAddress> getEndpoints(TokenRange range) { Set<Host> hostSet = rangeMap.get(range); List<InetAddress> addresses = new ArrayList<>(hostSet.size()); for (Host host : hostSet) { addresses.add(host.getAddress()); } return addresses; }
/* * When the set of live nodes change, the loadbalancer will change his * mind on host distances. It might change it on the node that came/left * but also on other nodes (for instance, if a node dies, another * previously ignored node may be now considered). * * This method ensures that all hosts for which a pool should exist * have one, and hosts that shouldn't don't. */ private void updateCreatedPools() { for (Host h : cluster.getMetadata().allHosts()) { HostDistance dist = loadBalancingPolicy().distance(h); HostConnectionPool pool = pools.get(h); if (pool == null) { if (dist != HostDistance.IGNORED && h.getMonitor().isUp()) addOrRenewPool(h); } else if (dist != pool.hostDistance) { if (dist == HostDistance.IGNORED) { removePool(h); } else { pool.hostDistance = dist; } } } }
public void onDown(Host host) { loadBalancer.onDown(host); HostConnectionPool pool = pools.remove(host); // This should not be necessary but it's harmless if (pool != null) pool.shutdown(); // If we've remove a host, the loadBalancer is allowed to change his mind on host distances. for (Host h : cluster.getMetadata().allHosts()) { if (!h.getMonitor().isUp()) continue; HostDistance dist = loadBalancer.distance(h); if (dist != HostDistance.IGNORED) { HostConnectionPool p = pools.get(h); if (p == null) addHost(host); else p.hostDistance = dist; } } }
private HostConnectionPool addHost(Host host) { try { HostDistance distance = loadBalancer.distance(host); if (distance == HostDistance.IGNORED) { return pools.get(host); } else { logger.debug("Adding {} to list of queried hosts", host); return pools.put(host, new HostConnectionPool(host, distance, this)); } } catch (AuthenticationException e) { logger.error("Error creating pool to {} ({})", host, e.getMessage()); host.getMonitor() .signalConnectionFailure(new ConnectionException(e.getHost(), e.getMessage())); return pools.get(host); } catch (ConnectionException e) { logger.debug("Error creating pool to {} ({})", host, e.getMessage()); host.getMonitor().signalConnectionFailure(e); return pools.get(host); } }
/** * Converts field annotations from Dexlib to Jimple * * @param h * @param f */ void handleFieldAnnotation(Host h, Field f) { Set<? extends Annotation> aSet = f.getAnnotations(); if (aSet != null && !aSet.isEmpty()) { List<Tag> tags = handleAnnotation(aSet, null); if (tags != null) for (Tag t : tags) if (t != null) { h.addTag(t); Debug.printDbg("add field annotation: ", t); } } }
public Connection borrowConnection(long timeout, TimeUnit unit) throws ConnectionException, TimeoutException { if (isShutdown.get()) // Note: throwing a ConnectionException is probably fine in practice as it will trigger the // creation of a new host. // That being said, maybe having a specific exception could be cleaner. throw new ConnectionException(host.getAddress(), "Pool is shutdown"); if (connections.isEmpty()) { for (int i = 0; i < options().getCoreConnectionsPerHost(hostDistance); i++) { // We don't respect MAX_SIMULTANEOUS_CREATION here because it's only to // protect against creating connection in excess of core too quickly scheduledForCreation.incrementAndGet(); manager.executor().submit(newConnectionTask); } Connection c = waitForConnection(timeout, unit); c.setKeyspace(manager.poolsState.keyspace); return c; } int minInFlight = Integer.MAX_VALUE; Connection leastBusy = null; for (Connection connection : connections) { int inFlight = connection.inFlight.get(); if (inFlight < minInFlight) { minInFlight = inFlight; leastBusy = connection; } } if (minInFlight >= options().getMaxSimultaneousRequestsPerConnectionThreshold(hostDistance) && connections.size() < options().getMaxConnectionsPerHost(hostDistance)) maybeSpawnNewConnection(); while (true) { int inFlight = leastBusy.inFlight.get(); if (inFlight >= Connection.MAX_STREAM_PER_CONNECTION) { leastBusy = waitForConnection(timeout, unit); break; } if (leastBusy.inFlight.compareAndSet(inFlight, inFlight + 1)) break; } leastBusy.setKeyspace(manager.poolsState.keyspace); return leastBusy; }
public void returnConnection(Connection connection) { int inFlight = connection.inFlight.decrementAndGet(); if (connection.isDefunct()) { if (host.getMonitor().signalConnectionFailure(connection.lastException())) shutdown(); else replace(connection); } else { if (trash.contains(connection) && inFlight == 0) { if (trash.remove(connection)) close(connection); return; } if (connections.size() > options().getCoreConnectionsPerHost(hostDistance) && inFlight <= options().getMinSimultaneousRequestsPerConnectionThreshold(hostDistance)) { trashConnection(connection); } else { signalAvailableConnection(); } } }
private boolean addConnectionIfUnderMaximum() { // First, make sure we don't cross the allowed limit of open connections for (; ; ) { int opened = open.get(); if (opened >= options().getMaxConnectionsPerHost(hostDistance)) return false; if (open.compareAndSet(opened, opened + 1)) break; } if (isShutdown()) { open.decrementAndGet(); return false; } // Now really open the connection try { connections.add(manager.connectionFactory().open(host)); signalAvailableConnection(); return true; } catch (InterruptedException e) { Thread.currentThread().interrupt(); // Skip the open but ignore otherwise open.decrementAndGet(); return false; } catch (ConnectionException e) { open.decrementAndGet(); logger.debug("Connection error to {} while creating additional connection", host); if (host.getMonitor().signalConnectionFailure(e)) shutdown(); return false; } catch (AuthenticationException e) { // This shouldn't really happen in theory open.decrementAndGet(); logger.error( "Authentication error while creating additional connection (error is: {})", e.getMessage()); shutdown(); return false; } }
private Connection waitForConnection(long timeout, TimeUnit unit) throws ConnectionException, TimeoutException { long start = System.nanoTime(); long remaining = timeout; do { try { awaitAvailableConnection(remaining, unit); } catch (InterruptedException e) { Thread.currentThread().interrupt(); // If we're interrupted fine, check if there is a connection available but stop waiting // otherwise timeout = 0; // this will make us stop the loop if we don't get a connection right away } if (isShutdown()) throw new ConnectionException(host.getAddress(), "Pool is shutdown"); int minInFlight = Integer.MAX_VALUE; Connection leastBusy = null; for (Connection connection : connections) { int inFlight = connection.inFlight.get(); if (inFlight < minInFlight) { minInFlight = inFlight; leastBusy = connection; } } while (true) { int inFlight = leastBusy.inFlight.get(); if (inFlight >= Connection.MAX_STREAM_PER_CONNECTION) break; if (leastBusy.inFlight.compareAndSet(inFlight, inFlight + 1)) return leastBusy; } remaining = timeout - Cluster.timeSince(start, unit); } while (remaining > 0); throw new TimeoutException(); }
public void run() { if (DiscoverEngine.getInstance().getStopStatus() == 1) return; snmp = SnmpUtil.getInstance(); SysLogger.info("开始分析设备" + node.getIpAddress() + "的地址转发表"); Set shieldList = DiscoverResource.getInstance().getShieldSet(); List netshieldList = DiscoverResource.getInstance().getNetshieldList(); List netincludeList = DiscoverResource.getInstance().getNetincludeList(); IfEntity ifEntity = null; IfEntity endifEntity = null; // 生成线程池 ThreadPool threadPool = new ThreadPool(addressList.size()); for (int i = 0; i < addressList.size(); i++) { // ################################### // 若不需要服务器,则不进行交换机的ARP表采集 // if(1==1)continue; // ################################### try { // node.updateCount(2); IpAddress ipAddr = (IpAddress) addressList.get(i); threadPool.runTask(NetMediThread.createTask(ipAddr, node)); // SysLogger.info("在"+node.getIpAddress()+"的地址转发表发现IP "+ipAddr.getIpAddress()+",开始分析"); } catch (Exception ex) { ex.printStackTrace(); } } // end_for // 关闭线程池并等待所有任务完成 threadPool.join(); threadPool.close(); threadPool = null; DiscoverEngine.getInstance().addDiscoverdcount(); snmp = null; setCompleted(true); } // end_run
public void analsysNDPHost(Host node, Host host) { if (host.getNdpHash() == null) host.setNdpHash(snmp.getNDPTable(host.getIpAddress(), host.getCommunity())); // 判断该NDP中是否包含node的MAC地址,若包含,则说明node是跟该设备直接连接关系 Hashtable hostNDPHash = host.getNdpHash(); if (host.getMac() == null) { String descr = (String) hostNDPHash.get(node.getMac()); IfEntity nodeIfEntity = node.getIfEntityByDesc(descr); Link link = new Link(); link.setStartId(node.getId()); link.setStartIndex(nodeIfEntity.getIndex()); link.setStartIp(node.getIpAddress()); link.setStartPhysAddress(node.getMac()); // 记录下起点的mac link.setStartDescr(descr); link.setEndIp(host.getIpAddress()); DiscoverEngine.getInstance().addHost(host, link); } else { if (node.getNdpHash() != null) { if (node.getNdpHash().containsKey(host.getMac())) { String hostdesc = (String) node.getNdpHash().get(host.getMac()); String descr = (String) hostNDPHash.get(node.getMac()); IfEntity nodeIfEntity = node.getIfEntityByDesc(descr); IfEntity hostIfEntity = host.getIfEntityByDesc(hostdesc); Link link = new Link(); link.setStartId(node.getId()); link.setStartIndex(nodeIfEntity.getIndex()); link.setStartIp(node.getIpAddress()); link.setStartPhysAddress(node.getMac()); // 记录下起点的mac link.setStartDescr(descr); link.setEndIndex(hostIfEntity.getIndex()); link.setEndIp(host.getIpAddress()); link.setEndPhysAddress(hostIfEntity.getPhysAddress()); link.setEndDescr(hostdesc); DiscoverEngine.getInstance().addHost(host, link); } else { String descr = (String) hostNDPHash.get(node.getMac()); IfEntity nodeIfEntity = node.getIfEntityByDesc(descr); Link link = new Link(); link.setStartId(node.getId()); link.setStartIndex(nodeIfEntity.getIndex()); link.setStartIp(node.getIpAddress()); link.setStartPhysAddress(node.getMac()); // 记录下起点的mac link.setStartDescr(descr); link.setEndIp(host.getIpAddress()); DiscoverEngine.getInstance().addHost(host, link); } } else { String descr = (String) hostNDPHash.get(node.getMac()); IfEntity nodeIfEntity = node.getIfEntityByDesc(descr); Link link = new Link(); link.setStartId(node.getId()); link.setStartIndex(nodeIfEntity.getIndex()); link.setStartIp(node.getIpAddress()); link.setStartPhysAddress(node.getMac()); // 记录下起点的mac link.setStartDescr(descr); link.setEndIp(host.getIpAddress()); DiscoverEngine.getInstance().addHost(host, link); } } }
public static void testTransactionTimeOut() { Host host = Host.getHost(0); VM vm0 = host.getVM(0); vm0.invoke(ExceptionsDUnitTest.class, "runTest3"); }
public static void testBlockingTimeOut() { Host host = Host.getHost(0); VM vm0 = host.getVM(0); vm0.invoke(ExceptionsDUnitTest.class, "runTest1"); }
public void setUp() throws Exception { super.setUp(); Host host = Host.getHost(0); VM vm0 = host.getVM(0); vm0.invoke(ExceptionsDUnitTest.class, "init"); }
/** Called by the sax parser when the start of an element is encountered. */ public void startElement(String nameSpaceURI, String local, String name, Attributes attrs) throws SAXException { try { Debug.println("processing " + name); if (name.compareTo(TagNames.CALLFLOW) == 0) { callFlow = new CallFlow(); callFlow.instantiateOn = attrs.getValue(Attr.instantiateOn); callFlow.description = attrs.getValue(Attr.description); } else if (name.compareTo(TagNames.AGENT) == 0) { Agent agent = new Agent(); agent.agentId = attrs.getValue(Attr.agentId); agent.userName = attrs.getValue(Attr.userName); agent.requestURI = attrs.getValue(Attr.requestURI); agent.host = attrs.getValue(Attr.host); agent.contactPort = attrs.getValue(Attr.contactPort); agent.contactHost = attrs.getValue(Attr.contactHost); addAgent(agent); } else if (name.compareTo(TagNames.EXPECT) == 0) { // Make sure there are no unexpected attributes. for (int i = 0; i < attrs.getLength(); i++) { String attrname = attrs.getLocalName(i); if (attrname.equals(Attr.enablingEvent) || attrname.equals(Attr.triggerMessage) || attrname.equals(Attr.generatedEvent) || attrname.equals(Attr.nodeId) || attrname.equals(Attr.onTrigger) || attrname.equals(Attr.onCompletion)) continue; else throw new SAXException( "Unkown attribute in expect: nodeId = " + attrs.getValue(Attr.nodeId) + " attribute name = " + attrname); } String enablingEvent = attrs.getValue(Attr.enablingEvent); String triggerMessage = attrs.getValue(Attr.triggerMessage); String generatedEvent = attrs.getValue(Attr.generatedEvent); String nodeId = attrs.getValue(Attr.nodeId); currentExpectNode = new Expect(callFlow, enablingEvent, generatedEvent, triggerMessage); String onTrigger = attrs.getValue(Attr.onTrigger); String onCompletion = attrs.getValue(Attr.onCompletion); currentExpectNode.onTrigger = onTrigger; currentExpectNode.onCompletion = onCompletion; currentExpectNode.nodeId = nodeId; } else if (name.compareTo(TagNames.SIP_REQUEST) == 0) { if (this.messageTemplateContext) { // This is a SIPRequest template node. for (int i = 0; i < attrs.getLength(); i++) { String attrname = attrs.getLocalName(i); if (!attrs.getLocalName(i).equals(Attr.templateId)) throw new SAXException( "Unkown attribute in SIP_REQUEST node " + " attribute name = " + attrname); } messageTemplate = new SIPRequest(); id = attrs.getValue(Attr.templateId); jythonCode = null; } } else if (name.compareTo(TagNames.SIP_RESPONSE) == 0) { if (this.messageTemplateContext) { messageTemplate = new SIPResponse(); jythonCode = null; for (int i = 0; i < attrs.getLength(); i++) { String attrname = attrs.getLocalName(i); if (!attrs.getLocalName(i).equals(Attr.templateId)) throw new SAXException( "Unkown attribute in SIP_REQUEST node " + " attribute name = " + attrname); } id = attrs.getValue(Attr.templateId); } } else if (name.compareTo(TagNames.STATUS_LINE) == 0) { String scode = attrs.getValue(Attr.statusCode); if (messageTemplateContext) { StatusLine statusLine = new StatusLine(); try { int statusCode = Integer.parseInt(scode); statusLine.setStatusCode(statusCode); } catch (NumberFormatException ex) { throw new SAXException(ex.getMessage()); } SIPResponse response = (SIPResponse) this.messageTemplate; response.setStatusLine(statusLine); } else { int statusCode = Integer.parseInt(scode); generatedMessage.addStatusLine(statusCode); } } else if (name.compareTo(TagNames.REQUEST_LINE) == 0) { String method = attrs.getValue(Attr.method); Debug.println("tagname = " + TagNames.REQUEST_LINE); Debug.println("messageTemplateContext = " + messageTemplateContext); if (messageTemplateContext) { for (int i = 0; i < attrs.getLength(); i++) { String attrname = attrs.getLocalName(i); if (attrs.getLocalName(i).equals(Attr.requestURI) || attrs.getLocalName(i).equals(Attr.method)) continue; else throw new SAXException( "Unkown attribute in REQUEST_LINE node " + " attribute name = " + attrname); } requestLine = new RequestLine(); requestLine.setMethod(method); String requestURI = attrs.getValue(Attr.requestURI); StringMsgParser smp = new StringMsgParser(); if (requestURI != null) { try { URI uri = smp.parseSIPUrl(requestURI); requestLine.setUri(uri); } catch (SIPParseException e) { throw new SAXException("Bad URL " + requestURI); } } SIPRequest request = (SIPRequest) messageTemplate; request.setRequestLine(requestLine); } else { for (int i = 0; i < attrs.getLength(); i++) { String attrname = attrs.getLocalName(i); if (attrs.getLocalName(i).equals(Attr.method) || attrs.getLocalName(i).equals(Attr.templateId) || attrs.getLocalName(i).equals(Attr.agentId)) continue; else throw new SAXException( "Unkown attribute in REQUEST_LINE node " + " attribute name = " + attrname); } String requestURI = attrs.getValue(Attr.requestURI); if (requestURI == null) { String agentId = attrs.getValue(Attr.agentId); if (agentId != null) { Agent agent = getAgent(agentId); if (agent == null) throw new SAXException("Missing requestURI or agent attribute"); requestURI = agent.requestURI; } } generatedMessage.addRequestLine(method, requestURI); } } else if (name.compareTo(TagNames.FROM) == 0) { for (int i = 0; i < attrs.getLength(); i++) { String attrname = attrs.getLocalName(i); if (attrs.getLocalName(i).equals(Attr.displayName) || attrs.getLocalName(i).equals(Attr.userName) || attrs.getLocalName(i).equals(Attr.host) || attrs.getLocalName(i).equals(Attr.agentId)) continue; else throw new SAXException( "Unkown attribute in FROM node " + " attribute name = " + attrname); } String displayName = attrs.getValue(Attr.displayName); String userName = attrs.getValue(Attr.userName); String hostName = attrs.getValue(Attr.host); String agentId = attrs.getValue(Attr.agentId); if (agentId != null) { Agent agent = getAgent(agentId); if (agent == null) throw new SAXException("agent not found " + agentId); if (displayName == null) displayName = agent.displayName; if (userName == null) userName = agent.userName; if (hostName == null) hostName = agent.host; } if (this.messageTemplateContext) { From from = new From(); Address address = new Address(); address.setDisplayName(displayName); URI uri = new URI(); Host host = new Host(); host.setHostname(hostName); uri.setHost(host); uri.setUser(userName); address.setAddrSpec(uri); from.setAddress(address); try { messageTemplate.attachHeader(from, false); } catch (SIPDuplicateHeaderException ex) { throw new SAXException(ex.getMessage()); } } else { generatedMessage.addFromHeader(displayName, userName, hostName); } } else if (name.compareTo(TagNames.TO) == 0) { for (int i = 0; i < attrs.getLength(); i++) { String attrname = attrs.getLocalName(i); if (attrs.getLocalName(i).equals(Attr.templateId) || attrs.getLocalName(i).equals(Attr.host) || attrs.getLocalName(i).equals(Attr.agentId) || attrs.getLocalName(i).equals(Attr.userName)) continue; else throw new SAXException( "Unkown attribute in FROM node " + " attribute name = " + attrname); } String displayName = attrs.getValue(Attr.displayName); String userName = attrs.getValue(Attr.userName); String hostName = attrs.getValue(Attr.host); String agentId = attrs.getValue(Attr.agentId); if (agentId != null) { Agent agent = getAgent(agentId); if (agent == null) throw new SAXException("agent not found " + agentId); if (displayName == null) displayName = agent.displayName; if (userName == null) userName = agent.userName; if (hostName == null) hostName = agent.host; } if (this.messageTemplateContext) { To to = new To(); Address address = new Address(); address.setDisplayName(displayName); URI uri = new URI(); Host host = new Host(); host.setHostname(hostName); uri.setHost(host); uri.setUser(userName); address.setAddrSpec(uri); to.setAddress(address); try { messageTemplate.attachHeader(to, false); } catch (SIPDuplicateHeaderException ex) { throw new SAXException(ex.getMessage()); } } else { generatedMessage.addToHeader(displayName, userName, hostName); } } else if (name.compareTo(TagNames.CALLID) == 0) { String lid = attrs.getValue(Attr.localId); String host = attrs.getValue(Attr.host); if (this.messageTemplateContext) { CallID cid = new CallID(); CallIdentifier cidf = new CallIdentifier(lid, host); cid.setCallIdentifier(cidf); } else { generatedMessage.addCallIdHeader(); } } else if (name.compareTo(TagNames.CONTACT) == 0) { for (int i = 0; i < attrs.getLength(); i++) { String attrname = attrs.getLocalName(i); if (attrs.getLocalName(i).equals(Attr.displayName) || attrs.getLocalName(i).equals(Attr.userName) || attrs.getLocalName(i).equals(Attr.action) || attrs.getLocalName(i).equals(Attr.contactHost) || attrs.getLocalName(i).equals(Attr.contactPort) || attrs.getLocalName(i).equals(Attr.agentId) || attrs.getLocalName(i).equals(Attr.expires)) continue; else throw new SAXException( "Unkown attribute in CONTACT node " + " attribute name = " + attrname); } String displayName = attrs.getValue(Attr.displayName); String userName = attrs.getValue(Attr.userName); String hostName = attrs.getValue(Attr.contactHost); String portString = attrs.getValue(Attr.contactPort); String expiryTimeString = attrs.getValue(Attr.expires); String action = attrs.getValue(Attr.action); String agentId = attrs.getValue(Attr.agentId); if (action == null) action = "proxy"; if (agentId != null) { Agent agent = getAgent(agentId); if (displayName == null) displayName = agent.displayName; if (userName == null) userName = agent.userName; if (hostName == null) hostName = agent.contactHost; if (portString == null) portString = agent.contactPort; } if (this.messageTemplateContext) { // Generating a message template for the expires header. ContactList clist = new ContactList(); Contact contact = new Contact(); clist.add(contact); URI uri = new URI(); Host host = new Host(); host.setHostname(hostName); uri.setHost(host); uri.setUser(userName); if (portString != null) { int port = new Integer(portString).intValue(); uri.setPort(port); } Address address = new Address(); address.setAddrSpec(uri); contact.setAddress(address); if (expiryTimeString != null) { long expiryTimeSec = new Long(expiryTimeString).longValue(); contact.setExpires(expiryTimeSec); } messageTemplate.attachHeader(clist, false); } else { int port = 5060; if (portString != null) port = new Integer(portString).intValue(); long expiryTimeSec = 3600; if (expiryTimeString != null) { expiryTimeSec = new Long(expiryTimeString).longValue(); } if (userName == null) throw new Exception("Missing attribute userName"); if (action == null) action = Attr.proxy; String uri; if (hostName == null) { uri = SIPKeywords.SIP + Separators.COLON + userName + Separators.AT + EventEngine.theStack.getHostAddress() + Separators.COLON + EventEngine.theStack.getDefaultPort() + Separators.SEMICOLON + SIPKeywords.TRANSPORT + Separators.EQUALS + EventEngine.theStack.getDefaultTransport(); } else uri = SIPKeywords.SIP + Separators.COLON + userName + Separators.AT + hostName + ":" + port; generatedMessage.addContactHeader(displayName, uri, expiryTimeSec, action); } } else if (name.compareTo(TagNames.GENERATE) == 0) { generateContext = true; if (currentExpectNode == null) { throw new SAXException("Bad element nesting."); } String id = attrs.getValue(Attr.messageId); String retransmit = attrs.getValue(Attr.retransmit); String delayString = attrs.getValue(Attr.delay); int delay = 0; if (delayString != null) { try { delay = Integer.parseInt(delayString); } catch (NumberFormatException ex) { throw new SAXException("Bad integer value " + delayString); } } generatedMessage = new GeneratedMessage(id, callFlow, currentExpectNode, retransmit); generatedMessage.delay = delay; currentExpectNode.addGeneratedMessage(generatedMessage); } else if (name.compareTo(TagNames.MESSAGE_TEMPLATES) == 0) { messageTemplateContext = true; } else if (name.compareTo(TagNames.JYTHON_CODE) == 0) { this.jythonCode = null; } else if (name.compareTo(TagNames.STATE_MACHINE) == 0) { } else if (name.compareTo(TagNames.AGENTS) == 0) { } else { throw new SAXException("Unkown tag " + name); } } catch (Exception ex) { ex.printStackTrace(); ex.fillInStackTrace(); throw new SAXException(ex.getMessage()); } }
/** * Converts method and method parameters annotations from Dexlib to Jimple * * @param h * @param method */ void handleMethodAnnotation(Host h, Method method) { Set<? extends Annotation> aSet = method.getAnnotations(); if (!(aSet == null || aSet.isEmpty())) { List<Tag> tags = handleAnnotation(aSet, null); if (tags != null) for (Tag t : tags) if (t != null) { h.addTag(t); Debug.printDbg("add method annotation: ", t); } } ArrayList<String> parameterNames = new ArrayList<String>(); boolean addParameterNames = false; for (MethodParameter p : method.getParameters()) { String name = p.getName(); parameterNames.add(name); if (name != null) addParameterNames = true; } if (addParameterNames) { h.addTag(new ParamNamesTag(parameterNames)); } // Is there any parameter annotation? boolean doParam = false; List<? extends MethodParameter> parameters = method.getParameters(); for (MethodParameter p : parameters) { Debug.printDbg("parameter ", p, " annotations: ", p.getAnnotations()); if (p.getAnnotations().size() > 0) { doParam = true; break; } } if (doParam) { VisibilityParameterAnnotationTag tag = new VisibilityParameterAnnotationTag( parameters.size(), AnnotationConstants.RUNTIME_VISIBLE); for (MethodParameter p : parameters) { List<Tag> tags = handleAnnotation(p.getAnnotations(), null); // If we have no tag for this parameter, add a placeholder // so that we keep the order intact. if (tags == null) { tag.addVisibilityAnnotation(null); continue; } VisibilityAnnotationTag paramVat = new VisibilityAnnotationTag(AnnotationConstants.RUNTIME_VISIBLE); tag.addVisibilityAnnotation(paramVat); for (Tag t : tags) { if (t == null) continue; AnnotationTag vat = null; if (!(t instanceof VisibilityAnnotationTag)) { if (t instanceof DeprecatedTag) { vat = new AnnotationTag("Ljava/lang/Deprecated;"); } else if (t instanceof SignatureTag) { SignatureTag sig = (SignatureTag) t; ArrayList<AnnotationElem> sigElements = new ArrayList<AnnotationElem>(); for (String s : SootToDexUtils.splitSignature(sig.getSignature())) sigElements.add(new AnnotationStringElem(s, 's', "value")); AnnotationElem elem = new AnnotationArrayElem(sigElements, 's', "value"); vat = new AnnotationTag("Ldalvik/annotation/Signature;", Collections.singleton(elem)); } else { throw new RuntimeException( "error: unhandled tag for parameter annotation in method " + h + " (" + t + ")."); } } else { vat = ((VisibilityAnnotationTag) t).getAnnotations().get(0); } Debug.printDbg("add parameter annotation: ", t); paramVat.addAnnotation(vat); } } if (tag.getVisibilityAnnotations().size() > 0) h.addTag(tag); } }
public void tearDown2() throws NamingException, SQLException { Host host = Host.getHost(0); VM vm0 = host.getVM(0); vm0.invoke(ExceptionsDUnitTest.class, "closeCache"); }
private VM getOtherVm() { Host host = Host.getHost(0); return host.getVM(0); }