Get the topology definition for the given topology

@return Topology
438204
public TopologyAPI.Topology getTopology(String topologyName) {
    return awaitResult(delegate.getTopology(null, topologyName));
  }
138212
public List<Map<String,String>> getMapsForTopology(SamzaTopology topology) throws Exception {

		List<Map<String,String>> maps = new ArrayList<Map<String,String>>();

		// File to write serialized objects
		String filename = topology.getTopologyName() + ".dat";
		Path dirPath = FileSystems.getDefault().getPath("dat");
		Path filePath= FileSystems.getDefault().getPath(dirPath.toString(), filename);
		String dstPath = filePath.toString();
		String resPath;
		String filesystem;
		if (this.isLocalMode) {
			filesystem = SystemsUtils.LOCAL_FS;
			File dir = dirPath.toFile();
			if (!dir.exists()) 
				FileUtils.forceMkdir(dir);
		}
		else {
			filesystem = SystemsUtils.HDFS;
		}

		// Correct system name for streams
		this.setSystemNameForStreams(topology.getStreams());
		
		// Add all PIs to a collection (map)
		Map<String,Object> piMap = new HashMap<String,Object>();
		Set<EntranceProcessingItem> entranceProcessingItems = topology.getEntranceProcessingItems();
		Set<IProcessingItem> processingItems = topology.getNonEntranceProcessingItems();
		for(EntranceProcessingItem epi:entranceProcessingItems) {
			SamzaEntranceProcessingItem sepi = (SamzaEntranceProcessingItem) epi;
			piMap.put(sepi.getName(), sepi);
		}
		for(IProcessingItem pi:processingItems) {
			SamzaProcessingItem spi = (SamzaProcessingItem) pi;
			piMap.put(spi.getName(), spi);
		}

		// Serialize all PIs
		boolean serialized = false;
		if (this.isLocalMode) {
			serialized = SystemsUtils.serializeObjectToLocalFileSystem(piMap, dstPath);
			resPath = dstPath;
		}
		else {
			resPath = SystemsUtils.serializeObjectToHDFS(piMap, dstPath);
			serialized = resPath != null;
		}

		if (!serialized) {
			throw new Exception("Fail serialize map of PIs to file");
		}

		// MapConfig for all PIs
		for(EntranceProcessingItem epi:entranceProcessingItems) {
			SamzaEntranceProcessingItem sepi = (SamzaEntranceProcessingItem) epi;
			maps.add(this.getMapForEntrancePI(sepi, resPath, filesystem));
		}
		for(IProcessingItem pi:processingItems) {
			SamzaProcessingItem spi = (SamzaProcessingItem) pi;
			maps.add(this.getMapForPI(spi, resPath, filesystem));
		}

		return maps;
	}
314043
public static Map<String, Double> getComponentCpuMapConfig(TopologyAPI.Topology topology)
      throws RuntimeException {
    Map<String, String> configMap =
        getComponentConfigMap(topology, Config.TOPOLOGY_COMPONENT_CPUMAP);
    Map<String, Double> cpuMap = new HashMap<>();

    for (Map.Entry<String, String> entry : configMap.entrySet()) {
      Double requiredCpu = Double.parseDouble(entry.getValue());
      cpuMap.put(entry.getKey(), requiredCpu);
    }
    return cpuMap;
  }
1234803
def get_topology(self):
        
        topology = {'name': self._name,
                    'resources_type': 'local',
                    'topology': {},
                    'type': 'topology',
                    'version': '1.0'}

        if self._links:
            topology['topology']['links'] = self._links
        if self._nodes:
            topology['topology']['nodes'] = self._nodes
        if self._servers:
            topology['topology']['servers'] = self._servers
        if self._notes:
            topology['topology']['notes'] = self._notes
        if self._shapes['ellipse']:
            topology['topology']['ellipses'] = self._shapes['ellipse']
        if self._shapes['rectangle']:
            topology['topology']['rectangles'] = \
                self._shapes['rectangle']
        if self._images:
            topology['topology']['images'] = self._images

        return topology
394744
public static Map<String, ByteAmount> getComponentDiskMapConfig(TopologyAPI.Topology topology)
      throws RuntimeException {
    Map<String, String> configMap =
        getComponentConfigMap(topology, Config.TOPOLOGY_COMPONENT_DISKMAP);
    Map<String, ByteAmount> diskMap = new HashMap<>();

    for (Map.Entry<String, String> entry : configMap.entrySet()) {
      long requiredDisk = Long.parseLong(entry.getValue());
      diskMap.put(entry.getKey(), ByteAmount.fromBytes(requiredDisk));
    }
    return diskMap;
  }
511087
public Graph<K, VV, EV> getUndirected() {

		DataSet<Edge<K, EV>> undirectedEdges = edges.
			flatMap(new RegularAndReversedEdgesMap<>()).name("To undirected graph");
		return new Graph<>(vertices, undirectedEdges, this.context);
	}
83821
public function getNode()
    {
        $node = hexdec(bin2hex(random_bytes(6)));

        // Set the multicast bit; see RFC 4122, section 4.5.
        $node = $node | 0x010000000000;

        return str_pad(dechex($node), 12, '0', STR_PAD_LEFT);
    }
458487
public static int getNumContainers(TopologyAPI.Topology topology) {
    List<TopologyAPI.Config.KeyValue> topologyConfig = topology.getTopologyConfig().getKvsList();
    return Integer.parseInt(TopologyUtils.getConfigWithDefault(
        topologyConfig, Config.TOPOLOGY_STMGRS, "1").trim());
  }
1149277
public function getNestedGraph(): NestedGraph
	{
		return $this->nestedGraph !== null
			? $this->nestedGraph
			: ($this->nestedGraph = $this->getRootGraph()->createNestedGraph($this));
	}
678326
public static boolean verifyTopology(TopologyAPI.Topology topology) {
    if (!topology.hasName() || topology.getName().isEmpty()) {
      LOG.severe("Missing topology name");
      return false;
    }
    if (topology.getName().contains(".") || topology.getName().contains("/")) {
      LOG.severe("Invalid topology name. Topology name shouldn't have . or /");
      return false;
    }

    // Only verify RAM map string well-formed.
    getComponentRamMapConfig(topology);
    // Verify all bolts input streams exist. First get all output streams.
    Set<String> outputStreams = new HashSet<>();
    for (TopologyAPI.Spout spout : topology.getSpoutsList()) {
      for (TopologyAPI.OutputStream stream : spout.getOutputsList()) {
        outputStreams.add(
            stream.getStream().getComponentName() + "/" + stream.getStream().getId());
      }
    }
    for (TopologyAPI.Bolt bolt : topology.getBoltsList()) {
      for (TopologyAPI.OutputStream stream : bolt.getOutputsList()) {
        outputStreams.add(
            stream.getStream().getComponentName() + "/" + stream.getStream().getId());
      }
    }
    // Match output streams with input streams.
    for (TopologyAPI.Bolt bolt : topology.getBoltsList()) {
      for (TopologyAPI.InputStream stream : bolt.getInputsList()) {
        String key = stream.getStream().getComponentName() + "/" + stream.getStream().getId();
        if (!outputStreams.contains(key)) {
          LOG.severe("Invalid input stream " + key + " existing streams are " + outputStreams);
          return false;
        }
      }
    }
    // TODO(nbhagat): Should we enforce all output stream must be consumed?

    return true;
  }
1338206
private Topology createAdHocTopologyFromSuitableOptions(SuitableOptions appInfoSuitableOptions) {

      Topology topology = new Topology();

      TopologyElement current = null;
      TopologyElement previous = null;

      for (String moduleName : appInfoSuitableOptions.getStringIterator()) {

         if (current == null) {
            // first element treated. None of them needs to point at it
            current = new TopologyElement(moduleName);
            topology.addModule(current);

         } else {// There were explored already other modules
            previous = current;
            current = new TopologyElement(moduleName);
            previous.addElementCalled(current);
            topology.addModule(current);
         }

      }

      return topology;

   }
1257784
public static function getMapping()
    {
        $instance = new static;
        $params = $instance->basicElasticParams();

        return $instance->getElasticClient()->indices()->getMapping($params);
    }
134837
private String getTopologyFromRandomNodeWithRetry(Set<Host> activeHosts) {
		int count = NUM_RETRIES_PER_NODE;
		String nodeResponse;
		Exception lastEx;
		final Host randomHost = getRandomHost(activeHosts);
		do {
			try {
				lastEx = null;
				nodeResponse = getResponseViaHttp(randomHost.getHostName());
				if (nodeResponse != null) {
					Logger.info("Received topology from " + randomHost);
					return nodeResponse;
				}
			} catch (Exception e) {
				Logger.info("cannot get topology from : " + randomHost);
				lastEx = e;
			} finally {
				count--;
			}

		} while ((count > 0));

		if (lastEx != null) {
			if (lastEx instanceof ConnectTimeoutException) {
				throw new TimeoutException("Unable to obtain topology", lastEx).setHost(randomHost);
			}
			throw new DynoException(String.format("Unable to obtain topology from %s", randomHost), lastEx);
		} else {
			throw new DynoException(String.format("Could not contact dynomite manager for token map on %s", randomHost));
		}

    }
398964
public function getTopology() {
		$descriptor = new Descriptor('Factory', self::TOPOLOGY_FRONTEND);
		
		if ($this->_defaultLifetime === null) {
			$descriptor->lifetime = 'n/a';
		} else {
			$descriptor->lifetime = $this->_defaultLifetime;
		}
		
		$descriptor->created = count($this->_wrappers);
		
		$backend = $this->getBackend();
		
		if ($backend instanceof TopologyInterface) {
			$descriptor[] = $backend->getTopology();
		}
		
		return $descriptor;
	}
26414
public List<VertexT> topologicalSort() {
    Preconditions.checkState(!wasSorted);
    wasSorted = true;

    Queue<VertexT> queue = new ArrayDeque<>();

    for (Map.Entry<VertexT, Integer> entry : vertices.entrySet()) {
      if (entry.getValue() == 0) {
        queue.add(entry.getKey());
      }
    }

    List<VertexT> result = Lists.newArrayList();
    while (!queue.isEmpty()) {
      VertexT vertex = queue.remove();
      result.add(vertex);
      for (VertexT successor : adjacencyList.get(vertex)) {
        if (decrementAndGetCount(successor) == 0) {
          queue.add(successor);
        }
      }
    }

    if (result.size() != vertices.size()) {
      throw new IllegalArgumentException("failed to perform topological sort, graph has a cycle");
    }

    return result;
  }
894259
public Map<ExecutorDetails, String> getNeedsSchedulingExecutorToComponents(TopologyDetails topology) {
        Collection<ExecutorDetails> allExecutors = new HashSet<>(topology.getExecutors());

        SchedulerAssignment assignment = this.assignments.get(topology.getId());
        if (assignment != null) {
            Collection<ExecutorDetails> assignedExecutors = assignment.getExecutors();
            allExecutors.removeAll(assignedExecutors);
        }

        return topology.selectExecutorToComponent(allExecutors);
    }
19637
public GeometryCollection generateVoronoi(int outputDimension) throws TopologyException {
        GeometryFactory geometryFactory = inputTriangles.getFactory();
        if(triangleNeighbors == null || triangleNeighbors.length == 0) {
            return geometryFactory.createMultiLineString(new LineString[0]);
        }
        Coordinate[] triangleCircumcenter = new Coordinate[inputTriangles.getNumGeometries()];
        if(outputDimension == 2 && envelope == null) {
            List<Polygon> polygons = new ArrayList<Polygon>(triangleCircumcenter.length);
            Set<Integer> processedVertex = new HashSet<Integer>();
            for (int idgeom = 0; idgeom < triangleCircumcenter.length; idgeom++) {
                    Geometry geomItem = inputTriangles.getGeometryN(idgeom);
                    if (geomItem instanceof Polygon) {
                        if(doProcessTriangle(idgeom, triangleCircumcenter)) {
                            Triple neigh = triangleNeighbors[idgeom];
                            for (int sideNeigh = 0; sideNeigh < 3; sideNeigh++) {
                                int neighIndex = neigh.get(sideNeigh);
                                for (int vertexSide = 0; vertexSide < 3; vertexSide++) {
                                    // If vertex is shared by this neighbor (see ascii art of triangle)
                                    if (vertexSide != sideNeigh) {
                                        int vertexIndex = triangleVertex[idgeom].get(vertexSide);
                                        if (neighIndex != -1 && !processedVertex.contains(vertexIndex)) {
                                            // Add voronoi edge between circumcentre of A and current triangle circumcenter
                                            Polygon result = generateVoronoiPolygon(idgeom, vertexIndex, triangleCircumcenter);
                                            if (result != null) {
                                                polygons.add(result);
                                            }
                                            processedVertex.add(vertexIndex);
                                        }
                                    }
                                }
                            }
                        }
                } else {
                    throw new TopologyException("Voronoi method accept only polygons");
                }
            }
            MultiPolygon result = geometryFactory.createMultiPolygon(polygons.toArray(new Polygon[0]));
            if(envelope == null) {
                return result;
            } else {
                return (GeometryCollection)geometryFactory.toGeometry(envelope).intersection(result);
            }
        } else if(outputDimension == 1 || (envelope != null && outputDimension == 2)) {
            //.. later
            List<LineString> lineStrings = new ArrayList<LineString>(triangleCircumcenter.length);
            List<LineString> voronoiBorderLines = new ArrayList<LineString>();
            for (int idgeom = 0; idgeom < triangleCircumcenter.length; idgeom++) {
                Geometry geomItem = inputTriangles.getGeometryN(idgeom);
                if (geomItem instanceof Polygon) {
                    if(doProcessTriangle(idgeom, triangleCircumcenter))  {
                        Triple neigh = triangleNeighbors[idgeom];
                        for(int side = 0;side < 3; side ++) {
                            int neighIndex = neigh.get(side);
                            if(neighIndex >= 0 && !doProcessTriangle(neighIndex, triangleCircumcenter)) {
                                neighIndex = -1;
                            }
                            // If segment not already processed
                            if (neighIndex > idgeom) {
                                LineString lineString = geometryFactory.createLineString(new Coordinate[]{getCircumcenter(idgeom,
                                        triangleCircumcenter), getCircumcenter(neighIndex, triangleCircumcenter)});
                                if(lineString.getLength() > epsilon) {
                                    lineStrings.add(lineString);
                                }
                            } else if(neighIndex == -1 && envelope != null) {
                                LineString lineString = voronoiSide(idgeom, side, geometryFactory,
                                        getCircumcenter(idgeom, triangleCircumcenter));
                                if(lineString != null) {
                                    voronoiBorderLines.add(lineString);
                                }
                            }
                        }
                    }
                } else {
                    throw new TopologyException("Voronoi method accept only polygons");
                }
            }
            // Generate envelope segments
            if(envelope != null) {
                voronoiBorderLines.add(((Polygon)geometryFactory.toGeometry(envelope)).getExteriorRing());
                MultiLineString env = (MultiLineString)geometryFactory.createMultiLineString(voronoiBorderLines.
                        toArray(new LineString[0])).union();
                for (int i = 0; i < env.getNumGeometries(); i++) {
                    lineStrings.add((LineString) env.getGeometryN(i));
                }
            }
            if(outputDimension == 1) {
                return geometryFactory.createMultiLineString(lineStrings.toArray(new LineString[0]));
            } else {
                Polygonizer polygonizer = new Polygonizer();
                MultiLineString voronoiSegs = geometryFactory.createMultiLineString(lineStrings.toArray(new LineString[0]));
                polygonizer.add(voronoiSegs);
                return geometryFactory.createMultiPolygon(GeometryFactory.toPolygonArray(polygonizer.getPolygons()));
            }
        } else {
            Coordinate[] circumcenters = new Coordinate[inputTriangles.getNumGeometries()];
            for (int idgeom = 0; idgeom < triangleCircumcenter.length; idgeom++) {
                Geometry geomItem = inputTriangles.getGeometryN(idgeom);
                if (geomItem instanceof Polygon) {
                    circumcenters[idgeom] = getCircumcenter(idgeom, triangleCircumcenter);
                }
            }
            MultiPoint result = geometryFactory.createMultiPoint(circumcenters);
            if(envelope == null) {
                return result;
            } else {
                return (GeometryCollection)geometryFactory.toGeometry(envelope).intersection(result);
            }
        }
    }