Tabnine Logo
NodesSpecifier
Code IndexAdd Tabnine to your IDE (free)

How to use
NodesSpecifier
in
org.batfish.datamodel.questions

Best Java code snippets using org.batfish.datamodel.questions.NodesSpecifier (Showing top 20 results out of 315)

origin: batfish/batfish

return new ShorthandNodeSpecifier(new NodesSpecifier(trimmedInput));
origin: batfish/batfish

/**
 * Prepares for calling the full auto complete function: {@link
 * NodesSpecifier#autoComplete(String, Set, NodeRolesData)} by extracting the set of nodes and
 * node roles from batfish pointer.
 *
 * @param query The query to auto complete
 * @param batfish The pointer to batfish
 * @return A list of {@link AutocompleteSuggestion} objects
 */
public static List<AutocompleteSuggestion> autoComplete(String query, IBatfish batfish) {
 return autoComplete(query, batfish.loadConfigurations().keySet(), batfish.getNodeRolesData());
}
origin: batfish/batfish

 @Override
 public Set<String> resolve(SpecifierContext ctxt) {
  return _shorthandSpecifier.getMatchingNodes(ctxt);
 }
}
origin: batfish/batfish

 public static LocationSpecifier from(@Nonnull NodesSpecifier ingressNodes) {
  switch (ingressNodes.getType()) {
   case NAME:
    return new NodeNameRegexInterfaceLocationSpecifier(ingressNodes.getRegex());
   case ROLE:
    return new NodeRoleRegexInterfaceLocationSpecifier(
      ingressNodes.getRoleDimension(), ingressNodes.getRegex());
   default:
    throw new BatfishException("Unexpected NodesSpecifier type: " + ingressNodes.getType());
  }
 }
}
origin: batfish/batfish

@JsonIgnore
/** Return the set of nodes that match this specifier */
public Set<String> getMatchingNodes(SpecifierContext ctxt) {
 switch (_type) {
  case NAME:
   return getMatchingNodesByName(ctxt.getConfigs().keySet());
  case ROLE:
   Optional<NodeRoleDimension> roleDimension = ctxt.getNodeRoleDimension(_roleDimension);
   if (roleDimension.isPresent()) {
    return getMatchingNodesByRole(roleDimension.get(), ctxt.getConfigs().keySet());
   } else {
    return Collections.emptySet();
   }
  default:
   throw new BatfishException("Unhandled NodesSpecifier type: " + _type);
 }
}
origin: batfish/batfish

@Test
public void constructorExplicitName() {
 NodesSpecifier specifier = new NodesSpecifier("name:lhr-.*");
 assertThat(specifier.getType(), equalTo(Type.NAME));
 assertThat(
   specifier.getRegex().pattern(),
   equalTo(Pattern.compile("lhr-.*", Pattern.CASE_INSENSITIVE).pattern()));
}
origin: batfish/batfish

@Test
public void constructorRole() {
 NodesSpecifier specifier = new NodesSpecifier("role:dim:svr.*");
 assertThat(specifier.getType(), equalTo(Type.ROLE));
 assertThat(specifier.getRoleDimension(), equalTo("dim"));
 assertThat(
   specifier.getRegex().pattern(),
   equalTo(Pattern.compile("svr.*", Pattern.CASE_INSENSITIVE).pattern()));
}
origin: batfish/batfish

Set<String> includeNodes = question.getNodeRegex().getMatchingNodes(_batfish);
Set<String> innerIncludeNodes = innerNRQuestion.getNodeRegex().getMatchingNodes(_batfish);
for (Map.Entry<String, SortedSet<String>> entry : roleNodeMap.entrySet()) {
 String role = entry.getKey();
 Set<String> roleNodes = entry.getValue();
 String regex = namesToRegex(Sets.intersection(innerIncludeNodes, roleNodes));
 innerNRQuestion.setNodeRegex(new NodesSpecifier(regex));
 Answerer innerAnswerer = _batfish.createAnswerer(innerQuestion);
 AnswerElement innerAnswer = innerAnswerer.answer();
origin: batfish/batfish

@Test
public void getMatchingNodesByName() {
 NodesSpecifier specifier = new NodesSpecifier("name:lhr-.*");
 String matchingRouter = "lhr-border1";
 String nonMatchingRouter = "svr-border1";
 Set<String> nodes =
   new ImmutableSet.Builder<String>().add(matchingRouter).add(nonMatchingRouter).build();
 Set<String> matchingNodes = specifier.getMatchingNodesByName(nodes);
 assertThat(matchingNodes, hasItem(matchingRouter));
 assertThat(matchingNodes, not(hasItem(nonMatchingRouter)));
}
origin: batfish/batfish

@Test
public void getMatchingNodesByRole() {
 NodesSpecifier specifier = new NodesSpecifier("role:dim:match.*");
   NodeRoleDimension.builder().setName("dim").setRoles(roles).build();
 Set<String> matchingNodes = specifier.getMatchingNodesByRole(roleDimension, nodes);
origin: batfish/batfish

.filter(nodesSpecifier.getRegex().asPredicate())
.forEach(
  node -> {
origin: batfish/batfish

@Test
public void constructorImplicitName() {
 NodesSpecifier specifier = new NodesSpecifier("lhr-.*");
 assertThat(specifier.getType(), equalTo(Type.NAME));
 assertThat(
   specifier.getRegex().pattern(),
   equalTo(Pattern.compile("lhr-.*", Pattern.CASE_INSENSITIVE).pattern()));
}
origin: batfish/batfish

 public static NodeSpecifier from(@Nullable NodesSpecifier nodesSpecifier) {
  if (nodesSpecifier == null) {
   return null;
  }

  switch (nodesSpecifier.getType()) {
   case NAME:
    return new NameRegexNodeSpecifier(nodesSpecifier.getRegex());
   case ROLE:
    return new RoleRegexNodeSpecifier(
      nodesSpecifier.getRegex(), nodesSpecifier.getRoleDimension());
   default:
    throw new BatfishException("Unexpected NodesSpecifier type: " + nodesSpecifier.getType());
  }
 }
}
origin: batfish/batfish

 @Test
 public void testDifference() {
  assertThat(
    new FlexibleNodeSpecifierFactory().buildNodeSpecifier("foo - bar"),
    equalTo(
      new DifferenceNodeSpecifier(
        new ShorthandNodeSpecifier(new NodesSpecifier("foo")),
        new ShorthandNodeSpecifier(new NodesSpecifier("bar")))));
 }
}
origin: batfish/batfish

/** Return the set of nodes that match this specifier */
public Set<String> getMatchingNodes(IBatfish batfish) {
 return getMatchingNodes(batfish.specifierContext());
}
origin: batfish/batfish

@Test
public void autoCompleteEmptyString() {
 Set<String> nodes = new HashSet<>();
 nodes.add("node1");
 String query = "";
 List<AutocompleteSuggestion> suggestions = NodesSpecifier.autoComplete(query, nodes, null);
 // autocomplete should yield four entries: NAME:, ROLE:, .*, node1
 assertThat(suggestions, hasSize(4));
}
origin: batfish/batfish

@Test
public void testLimitRemoteNodes() {
 BgpSessionCompatibilityQuestion q =
   new BgpSessionCompatibilityQuestion(null, new NodesSpecifier("node1"), null, null);
 Multiset<Row> rows = getQuestionResults(q);
 assertThat(rows, equalTo(ImmutableMultiset.of(ROW_2)));
}
origin: batfish/batfish

@Override
public NodesAnswerElement answer() {
 NodesQuestion question = (NodesQuestion) _question;
 Map<String, Configuration> configurations = _batfish.loadConfigurations();
 // initRemoteBgpNeighbors(_batfish, configurations);
 SortedMap<String, Configuration> answerNodes = new TreeMap<>();
 Set<String> nodes = question.getNodes().getMatchingNodes(_batfish);
 for (String node : configurations.keySet()) {
  if (nodes.contains(node)) {
   answerNodes.put(node, configurations.get(node));
  }
 }
 return new NodesAnswerElement(answerNodes, question.getSummary());
}
origin: batfish/batfish

@Test
public void autoCompleteNothing() {
 Set<String> nodes = new HashSet<>();
 nodes.add("node1");
 String query = "matchNothing";
 List<AutocompleteSuggestion> suggestions = NodesSpecifier.autoComplete(query, nodes, null);
 // autocomplete should yield nothing
 assertThat(suggestions, hasSize(0));
}
origin: batfish/batfish

@Test
public void testLimitNodes() {
 BgpSessionCompatibilityQuestion q =
   new BgpSessionCompatibilityQuestion(new NodesSpecifier("node1"), null, null, null);
 Multiset<Row> rows = getQuestionResults(q);
 assertThat(rows, equalTo(ImmutableMultiset.of(ROW_1)));
}
org.batfish.datamodel.questionsNodesSpecifier

Javadoc

Enables specification of groups of nodes in various questions.

Currently supported example specifiers:

  • lhr-.* -> all nodes with matching names (old style)
  • name:lhr-.* -> same as above; name: is optional
  • role:auto0:a1.* -> all nodes with roles that match a1.* in role dimension auto0

In the future, we might need other tags (e.g., loc:) and boolean expressions (e.g., role:auto1.a1 AND lhr-* for all servers with matching names)

Most used methods

  • <init>
  • autoComplete
    Prepares for calling the full auto complete function: NodesSpecifier#autoComplete(String,Set,NodeRol
  • getMatchingNodes
  • getRegex
  • getMatchingNodesByName
  • getMatchingNodesByRole
  • getRoleDimension
  • getType
  • equals
  • nodeNameInMatchingRole
    Does this nodeName match any of roles that match our _regex?

Popular in Java

  • Reactive rest calls using spring rest template
  • findViewById (Activity)
  • setScale (BigDecimal)
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • MessageDigest (java.security)
    Uses a one-way hash function to turn an arbitrary number of bytes into a fixed-length byte sequence.
  • Dictionary (java.util)
    Note: Do not use this class since it is obsolete. Please use the Map interface for new implementatio
  • TimerTask (java.util)
    The TimerTask class represents a task to run at a specified time. The task may be run once or repeat
  • ExecutorService (java.util.concurrent)
    An Executor that provides methods to manage termination and methods that can produce a Future for tr
  • JarFile (java.util.jar)
    JarFile is used to read jar entries and their associated data from jar files.
  • Servlet (javax.servlet)
    Defines methods that all servlets must implement. A servlet is a small Java program that runs within
  • Best plugins for Eclipse
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now