Java Code Examples for org.apache.storm.utils.Utils#javaDeserialize()

The following examples show how to use org.apache.storm.utils.Utils#javaDeserialize() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StormAtlasHook.java    From atlas with Apache License 2.0 6 votes vote down vote up
private void addTopologyOutputs(StormTopology stormTopology, String topologyOwner, Map stormConf, AtlasEntity topology, AtlasEntityExtInfo entityExtInfo) {
    List<AtlasEntity> outputs   = new ArrayList<>();
    Map<String, Bolt> bolts     = stormTopology.get_bolts();
    Set<String>       boltNames = StormTopologyUtil.getTerminalUserBoltNames(stormTopology);

    for (String boltName : boltNames) {
        Serializable instance = Utils.javaDeserialize(bolts.get(boltName).get_bolt_object().get_serialized_java(), Serializable.class);
        String       dsType   = instance.getClass().getSimpleName();
        AtlasEntity  dsEntity = addDataSet(dsType, topologyOwner, instance, stormConf, entityExtInfo);

        if (dsEntity != null) {
            outputs.add(dsEntity);
        }
    }

    topology.setRelationshipAttribute("outputs", AtlasTypeUtil.getAtlasRelatedObjectIds(outputs, RELATIONSHIP_PROCESS_DATASET_OUTPUTS));
}
 
Example 2
Source File: StormAtlasHook.java    From incubator-atlas with Apache License 2.0 6 votes vote down vote up
private void addTopologyInputs(Referenceable topologyReferenceable,
                               Map<String, SpoutSpec> spouts,
                               Map stormConf,
                               String topologyOwner, List<Referenceable> dependentEntities) throws IllegalAccessException {
    final ArrayList<Referenceable> inputDataSets = new ArrayList<>();
    for (Map.Entry<String, SpoutSpec> entry : spouts.entrySet()) {
        Serializable instance = Utils.javaDeserialize(
                entry.getValue().get_spout_object().get_serialized_java(), Serializable.class);

        String simpleName = instance.getClass().getSimpleName();
        final Referenceable datasetRef = createDataSet(simpleName, topologyOwner, instance, stormConf, dependentEntities);
        if (datasetRef != null) {
            inputDataSets.add(datasetRef);
        }
    }

    topologyReferenceable.set("inputs", inputDataSets);
}
 
Example 3
Source File: StormAtlasHook.java    From incubator-atlas with Apache License 2.0 6 votes vote down vote up
private void addTopologyOutputs(Referenceable topologyReferenceable,
                                StormTopology stormTopology, String topologyOwner,
                                Map stormConf, List<Referenceable> dependentEntities) throws Exception {
    final ArrayList<Referenceable> outputDataSets = new ArrayList<>();

    Map<String, Bolt> bolts = stormTopology.get_bolts();
    Set<String> terminalBoltNames = StormTopologyUtil.getTerminalUserBoltNames(stormTopology);
    for (String terminalBoltName : terminalBoltNames) {
        Serializable instance = Utils.javaDeserialize(bolts.get(terminalBoltName)
                .get_bolt_object().get_serialized_java(), Serializable.class);

        String dataSetType = instance.getClass().getSimpleName();
        final Referenceable datasetRef = createDataSet(dataSetType, topologyOwner, instance, stormConf, dependentEntities);
        if (datasetRef != null) {
            outputDataSets.add(datasetRef);
        }
    }

    topologyReferenceable.set("outputs", outputDataSets);
}
 
Example 4
Source File: StormAtlasHook.java    From atlas with Apache License 2.0 5 votes vote down vote up
private void addTopologyInputs(Map<String, SpoutSpec> spouts, Map stormConf, String topologyOwner, AtlasEntity topology, AtlasEntityExtInfo entityExtInfo) {
    List<AtlasEntity> inputs = new ArrayList<>();

    for (Map.Entry<String, SpoutSpec> entry : spouts.entrySet()) {
        Serializable instance = Utils.javaDeserialize(entry.getValue().get_spout_object().get_serialized_java(), Serializable.class);
        String       dsType   = instance.getClass().getSimpleName();
        AtlasEntity  dsEntity = addDataSet(dsType, topologyOwner, instance, stormConf, entityExtInfo);

        if (dsEntity != null) {
            inputs.add(dsEntity);
        }
    }

    topology.setRelationshipAttribute("inputs", AtlasTypeUtil.getAtlasRelatedObjectIds(inputs, RELATIONSHIP_DATASET_PROCESS_INPUTS));
}
 
Example 5
Source File: StormAtlasHook.java    From atlas with Apache License 2.0 5 votes vote down vote up
private AtlasEntity createSpoutInstance(String spoutName, SpoutSpec stormSpout) {
    AtlasEntity         spout         = new AtlasEntity(StormDataTypes.STORM_SPOUT.getName());
    Serializable        instance      = Utils.javaDeserialize(stormSpout.get_spout_object().get_serialized_java(), Serializable.class);
    Map<String, String> flatConfigMap = StormTopologyUtil.getFieldValues(instance, true, null);

    spout.setAttribute(AtlasClient.NAME, spoutName);
    spout.setAttribute("driverClass", instance.getClass().getName());
    spout.setAttribute("conf", flatConfigMap);

    return spout;
}
 
Example 6
Source File: StormAtlasHook.java    From atlas with Apache License 2.0 5 votes vote down vote up
private AtlasEntity createBoltInstance(String boltName, Bolt stormBolt) {
    AtlasEntity         bolt          = new AtlasEntity(StormDataTypes.STORM_BOLT.getName());
    Serializable        instance      = Utils.javaDeserialize(stormBolt.get_bolt_object().get_serialized_java(), Serializable.class);
    Map<String, String> flatConfigMap = StormTopologyUtil.getFieldValues(instance, true, null);

    bolt.setAttribute(AtlasClient.NAME, boltName);
    bolt.setAttribute("driverClass", instance.getClass().getName());
    bolt.setAttribute("conf", flatConfigMap);

    return bolt;
}
 
Example 7
Source File: StormAtlasHook.java    From incubator-atlas with Apache License 2.0 5 votes vote down vote up
private Referenceable createSpoutInstance(String spoutName,
                                          SpoutSpec stormSpout) throws IllegalAccessException {
    Referenceable spoutReferenceable = new Referenceable(StormDataTypes.STORM_SPOUT.getName());
    spoutReferenceable.set(AtlasClient.NAME, spoutName);

    Serializable instance = Utils.javaDeserialize(
            stormSpout.get_spout_object().get_serialized_java(), Serializable.class);
    spoutReferenceable.set("driverClass", instance.getClass().getName());

    Map<String, String> flatConfigMap = StormTopologyUtil.getFieldValues(instance, true, null);
    spoutReferenceable.set("conf", flatConfigMap);

    return spoutReferenceable;
}
 
Example 8
Source File: StormAtlasHook.java    From incubator-atlas with Apache License 2.0 5 votes vote down vote up
private Referenceable createBoltInstance(String boltName,
                                         Bolt stormBolt) throws IllegalAccessException {
    Referenceable boltReferenceable = new Referenceable(StormDataTypes.STORM_BOLT.getName());

    boltReferenceable.set(AtlasClient.NAME, boltName);

    Serializable instance = Utils.javaDeserialize(
            stormBolt.get_bolt_object().get_serialized_java(), Serializable.class);
    boltReferenceable.set("driverClass", instance.getClass().getName());

    Map<String, String> flatConfigMap = StormTopologyUtil.getFieldValues(instance, true, null);
    boltReferenceable.set("conf", flatConfigMap);

    return boltReferenceable;
}