[EAGLE-530] Fix checkstyle problems on eagle-alert module and enable failOnViolation
https://issues.apache.org/jira/browse/EAGLE-530 Author: Hao Chen <h...@apache.org> Closes #424 from haoch/EAGLE-530. Project: http://git-wip-us.apache.org/repos/asf/incubator-eagle/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-eagle/commit/a0fc8708 Tree: http://git-wip-us.apache.org/repos/asf/incubator-eagle/tree/a0fc8708 Diff: http://git-wip-us.apache.org/repos/asf/incubator-eagle/diff/a0fc8708 Branch: refs/heads/master Commit: a0fc870849a5fa5d54c0980b21226977eef81920 Parents: 2958bc8 Author: Hao Chen <h...@apache.org> Authored: Thu Sep 8 15:13:33 2016 +0800 Committer: Hao Chen <h...@apache.org> Committed: Thu Sep 8 15:13:33 2016 +0800 ---------------------------------------------------------------------- .../eagle/alert/app/AlertUnitTopologyApp.java | 10 +- .../alert/resolver/AttributeResolvable.java | 8 +- .../resolver/AttributeResolveException.java | 16 +- .../resolver/AttributeResolveResource.java | 40 +- .../resolver/AttributeResolverFactory.java | 22 +- .../BadAttributeResolveRequestException.java | 6 +- .../GenericAttributeResolveRequest.java | 10 +- .../resolver/impl/BooleanAttributeResolver.java | 4 +- .../resolver/impl/EntityAttributeResolver.java | 63 +- .../eagle-alert/alert-common/pom.xml | 4 +- .../eagle/alert/config/ConfigBusBase.java | 23 +- .../eagle/alert/config/ConfigBusConsumer.java | 8 +- .../eagle/alert/config/ConfigBusProducer.java | 19 +- .../apache/eagle/alert/config/ConfigValue.java | 4 +- .../org/apache/eagle/alert/config/ZKConfig.java | 4 +- .../eagle/alert/config/ZKConfigBuilder.java | 2 +- .../alert/coordination/model/AlertBoltSpec.java | 35 +- .../coordination/model/Kafka2TupleMetadata.java | 9 +- .../coordination/model/PolicyWorkerQueue.java | 29 +- .../alert/coordination/model/PublishSpec.java | 8 +- .../alert/coordination/model/RouterSpec.java | 4 - .../alert/coordination/model/ScheduleState.java | 34 +- .../alert/coordination/model/SpoutSpec.java | 34 +- .../coordination/model/StreamNameSelector.java | 6 +- .../model/StreamRepartitionMetadata.java | 10 +- .../model/StreamRepartitionStrategy.java | 14 +- .../coordination/model/StreamRouterSpec.java | 19 +- .../model/Tuple2StreamConverter.java | 52 +- .../model/Tuple2StreamMetadata.java | 20 +- .../model/VersionedPolicyDefinition.java | 4 - .../model/VersionedStreamDefinition.java | 4 - .../alert/coordination/model/WorkSlot.java | 4 +- .../model/internal/MonitoredStream.java | 17 +- .../model/internal/PolicyAssignment.java | 5 +- .../model/internal/ScheduleStateBase.java | 7 +- .../model/internal/StreamGroup.java | 15 +- .../model/internal/StreamWorkSlotQueue.java | 32 +- .../coordination/model/internal/Topology.java | 10 +- .../alert/engine/codec/IEventSerializer.java | 3 +- .../engine/coordinator/PolicyDefinition.java | 92 +-- .../alert/engine/coordinator/Publishment.java | 11 +- .../engine/coordinator/PublishmentType.java | 32 +- .../alert/engine/coordinator/StreamColumn.java | 32 +- .../engine/coordinator/StreamDefinition.java | 34 +- .../engine/coordinator/StreamPartition.java | 56 +- .../engine/coordinator/StreamSortSpec.java | 49 +- .../engine/coordinator/StreamingCluster.java | 8 +- .../alert/engine/model/AlertStreamEvent.java | 14 +- .../alert/engine/model/PartitionedEvent.java | 64 +- .../eagle/alert/engine/model/StreamEvent.java | 55 +- .../alert/engine/model/StreamEventBuilder.java | 39 +- .../eagle/alert/metric/IMetricSystem.java | 39 +- .../apache/eagle/alert/metric/MetricSystem.java | 56 +- .../eagle/alert/metric/entity/MetricEvent.java | 63 +- .../alert/metric/reporter/KafkaReporter.java | 361 ++++++----- .../eagle/alert/metric/sink/ConsoleSink.java | 21 +- .../alert/metric/sink/ElasticSearchSink.java | 23 +- .../apache/eagle/alert/metric/sink/JmxSink.java | 5 +- .../eagle/alert/metric/sink/KafkaSink.java | 36 +- .../eagle/alert/metric/sink/MetricSink.java | 9 +- .../alert/metric/sink/MetricSinkRepository.java | 32 +- .../eagle/alert/metric/sink/Slf4jSink.java | 52 +- .../alert/metric/source/JVMMetricSource.java | 18 +- .../eagle/alert/metric/source/MetricSource.java | 11 +- .../metric/source/MetricSourceWrapper.java | 12 +- .../eagle/alert/resource/SimpleCORSFiler.java | 7 +- .../alert/service/IMetadataServiceClient.java | 29 +- .../service/MetadataServiceClientImpl.java | 33 +- .../eagle/alert/utils/AlertConstants.java | 18 +- .../org/apache/eagle/alert/utils/ByteUtils.java | 304 ++++----- .../apache/eagle/alert/utils/ConfigUtils.java | 23 +- .../apache/eagle/alert/utils/DateTimeUtil.java | 199 +++--- .../org/apache/eagle/alert/utils/HostUtils.java | 2 +- .../apache/eagle/alert/utils/KafkaEmbedded.java | 10 +- .../eagle/alert/utils/StreamIdConversion.java | 25 +- .../eagle/alert/utils/TimePeriodUtils.java | 27 +- .../eagle/alert/utils/ZookeeperEmbedded.java | 9 +- .../src/main/resources/log4j.properties | 2 - .../eagle/alert/config/TestConfigBus.java | 18 +- .../eagle/alert/metric/MetricSystemTest.java | 63 +- .../service/TestMetadataServiceClientImpl.java | 6 +- .../src/test/resources/application.conf | 24 +- .../src/test/resources/log4j.properties | 2 - .../src/test/resources/streamDef.json | 83 +-- .../eagle-alert/alert-coordinator/pom.xml | 12 +- .../eagle/alert/coordinator/Coordinator.java | 258 ++++---- .../alert/coordinator/CoordinatorConstants.java | 4 - .../alert/coordinator/CoordinatorListener.java | 18 +- .../alert/coordinator/ExclusiveExecutor.java | 126 ++-- .../alert/coordinator/IPolicyScheduler.java | 3 +- .../alert/coordinator/IScheduleContext.java | 9 +- .../LockWebApplicationException.java | 14 +- .../coordinator/PolicySchedulerFactory.java | 3 +- .../eagle/alert/coordinator/ScheduleOption.java | 6 +- .../alert/coordinator/TopologyMgmtService.java | 16 +- .../coordinator/impl/GreedyPolicyScheduler.java | 105 ++-- .../impl/MonitorMetadataGenerator.java | 63 +- .../alert/coordinator/impl/ScheduleResult.java | 9 +- .../coordinator/impl/WorkQueueBuilder.java | 15 +- .../impl/strategies/IWorkSlotStrategy.java | 6 +- .../strategies/SameTopologySlotStrategy.java | 46 +- .../alert/coordinator/model/AlertBoltUsage.java | 16 +- .../alert/coordinator/model/GroupBoltUsage.java | 34 +- .../alert/coordinator/model/TopologyUsage.java | 10 +- .../provider/InMemScheduleConext.java | 14 +- .../provider/NodataMetadataGenerator.java | 617 +++++++++---------- .../provider/ScheduleContextBuilder.java | 82 ++- .../resource/CoordinatorResource.java | 20 +- .../coordinator/trigger/CoordinatorTrigger.java | 19 +- .../trigger/DynamicPolicyLoader.java | 29 +- .../trigger/PolicyChangeListener.java | 3 +- .../alert/coordinator/CoordinatorTest.java | 7 +- .../coordinator/DynamicPolicyLoaderTest.java | 2 +- .../MetadataServiceClientImplTest.java | 1 - .../NodataMetadataGeneratorTest.java | 126 ++-- .../coordinator/ScheduleContextBuilderTest.java | 59 +- .../apache/alert/coordinator/SchedulerTest.java | 6 +- .../coordinator/TestExclusiveExecutor.java | 112 ++-- .../TestGreedyScheduleCoordinator.java | 208 ++++--- .../alert/coordinator/WorkSlotStrategyTest.java | 6 +- .../mock/InMemMetadataServiceClient.java | 5 +- .../mock/TestTopologyMgmtService.java | 2 +- .../src/test/resources/application.conf | 68 +- .../src/test/resources/log4j.properties | 2 - .../src/test/resources/multi/datasources.json | 34 +- .../src/test/resources/multi/publishments.json | 52 +- .../test/resources/multi/streamdefinitions.json | 286 +++++---- .../src/test/resources/multi/topologies.json | 58 +- .../src/test/resources/test-application.conf | 68 +- .../alert-devtools/conf/kafka-server.properties | 28 - .../alert/tools/KafkaConsumerOffsetFetcher.java | 7 +- .../alert/tools/KafkaLatestOffsetFetcher.java | 22 +- .../eagle/contrib/kafka/ProducerTool.scala | 4 +- .../eagle/alert/tools/TestKafkaOffset.java | 8 +- .../kafka-offset-test.application.conf | 16 +- .../src/test/resources/log4j.properties | 2 - .../eagle-alert/alert-engine/pom.xml | 13 +- .../alert/engine/AlertStreamCollector.java | 3 +- .../apache/eagle/alert/engine/Collector.java | 2 +- .../alert/engine/PartitionedEventCollector.java | 4 +- .../eagle/alert/engine/StreamContext.java | 1 - .../eagle/alert/engine/StreamContextImpl.java | 3 +- .../eagle/alert/engine/UnitTopologyMain.java | 26 +- .../IMetadataChangeNotifyService.java | 18 +- .../StreamDefinitionNotFoundException.java | 10 +- .../AbstractMetadataChangeNotifyService.java | 29 +- .../impl/ZKMetadataChangeNotifyService.java | 122 ++-- .../evaluator/CompositePolicyHandler.java | 5 +- .../engine/evaluator/PolicyChangeListener.java | 18 +- .../engine/evaluator/PolicyGroupEvaluator.java | 8 +- .../engine/evaluator/PolicyHandlerContext.java | 15 +- .../engine/evaluator/PolicyStreamHandler.java | 16 +- .../engine/evaluator/PolicyStreamHandlers.java | 8 +- .../evaluator/absence/AbsenceAlertDriver.java | 11 +- .../evaluator/absence/AbsenceDailyRule.java | 2 +- .../evaluator/absence/AbsencePolicyHandler.java | 60 +- .../engine/evaluator/absence/AbsenceWindow.java | 2 +- .../absence/AbsenceWindowGenerator.java | 18 +- .../absence/AbsenceWindowProcessor.java | 41 +- ...ertBoltOutputCollectorThreadSafeWrapper.java | 33 +- .../impl/AlertBoltOutputCollectorWrapper.java | 7 +- .../evaluator/impl/AlertStreamCallback.java | 15 +- .../impl/PolicyGroupEvaluatorImpl.java | 57 +- .../evaluator/impl/SiddhiDefinitionAdapter.java | 133 ++-- .../evaluator/impl/SiddhiPolicyHandler.java | 52 +- .../impl/SiddhiPolicyStateHandler.java | 8 +- .../nodata/DistinctValuesInTimeBatchWindow.java | 196 +++--- .../nodata/DistinctValuesInTimeWindow.java | 65 +- .../evaluator/nodata/NoDataPolicyHandler.java | 113 ++-- .../nodata/NoDataPolicyTimeBatchHandler.java | 252 ++++---- .../evaluator/nodata/NoDataWisbParser.java | 3 +- .../nodata/NoDataWisbProvidedParser.java | 12 +- .../engine/publisher/AlertDeduplicator.java | 4 +- .../engine/publisher/AlertPublishListener.java | 14 +- .../engine/publisher/AlertPublishPlugin.java | 10 +- .../publisher/AlertPublishSpecListener.java | 16 +- .../alert/engine/publisher/AlertPublisher.java | 23 +- .../eagle/alert/engine/publisher/AlertSink.java | 18 +- .../publisher/email/AlertEmailContext.java | 12 +- .../publisher/email/AlertEmailGenerator.java | 28 +- .../email/AlertEmailGeneratorBuilder.java | 22 +- .../publisher/email/AlertEmailSender.java | 49 +- .../engine/publisher/email/EagleMailClient.java | 399 ++++++------ .../publisher/impl/AbstractPublishPlugin.java | 11 +- .../publisher/impl/AlertEmailPublisher.java | 48 +- .../publisher/impl/AlertKafkaPublisher.java | 19 +- .../impl/AlertPublishPluginsFactory.java | 7 +- .../publisher/impl/AlertPublisherImpl.java | 54 +- .../publisher/impl/DefaultDeduplicator.java | 229 ++++--- .../alert/engine/publisher/impl/EventUniq.java | 80 +-- .../publisher/impl/JsonEventSerializer.java | 3 +- .../publisher/impl/KafkaProducerManager.java | 16 +- .../engine/publisher/impl/PublishStatus.java | 6 +- .../publisher/impl/StringEventSerializer.java | 9 +- .../engine/router/AlertBoltSpecListener.java | 4 +- .../alert/engine/router/SpoutSpecListener.java | 4 +- .../eagle/alert/engine/router/StreamRoute.java | 45 +- .../router/StreamRoutePartitionFactory.java | 6 +- .../engine/router/StreamRoutePartitioner.java | 10 +- .../engine/router/StreamRouteSpecListener.java | 18 +- .../eagle/alert/engine/router/StreamRouter.java | 21 +- .../router/StreamRouterBoltSpecListener.java | 8 +- .../alert/engine/router/StreamSortHandler.java | 12 +- .../engine/router/StreamSortSpecListener.java | 16 +- .../impl/BasicStreamRoutePartitioner.java | 22 +- .../router/impl/RoutePhysicalGrouping.java | 37 +- .../engine/router/impl/ShuffleGrouping.java | 21 +- .../impl/StreamRouterBoltOutputCollector.java | 78 ++- .../engine/router/impl/StreamRouterImpl.java | 44 +- .../alert/engine/runner/AbstractStreamBolt.java | 43 +- .../eagle/alert/engine/runner/AlertBolt.java | 72 +-- .../alert/engine/runner/AlertPublisherBolt.java | 31 +- .../alert/engine/runner/MapComparator.java | 21 +- .../engine/runner/StormMetricConsumer.java | 69 +-- .../runner/StormMetricTaggedConsumer.java | 67 +- .../alert/engine/runner/StreamRouterBolt.java | 46 +- .../alert/engine/runner/UnitTopologyRunner.java | 126 ++-- .../eagle/alert/engine/scheme/JsonScheme.java | 23 +- .../scheme/JsonStringStreamNameSelector.java | 19 +- .../alert/engine/scheme/PlainStringScheme.java | 19 +- .../scheme/PlainStringStreamNameSelector.java | 14 +- .../PartitionedEventDigestSerializer.java | 16 +- .../PartitionedEventSerializer.java | 17 +- .../SerializationMetadataProvider.java | 6 +- .../alert/engine/serialization/Serializer.java | 3 +- .../alert/engine/serialization/Serializers.java | 47 +- .../serialization/impl/BooleanSerializer.java | 4 +- .../serialization/impl/DoubleSerializer.java | 4 +- .../serialization/impl/FloatSerializer.java | 4 +- .../serialization/impl/IntegerSerializer.java | 4 +- .../impl/JavaObjectSerializer.java | 6 +- .../serialization/impl/LongSerializer.java | 4 +- .../impl/PartitionedEventSerializerImpl.java | 39 +- .../impl/StreamEventSerializer.java | 53 +- .../impl/StreamPartitionDigestSerializer.java | 38 +- .../impl/StreamPartitionSerializer.java | 26 +- .../serialization/impl/StringSerializer.java | 4 +- .../extension/AttributeCollectAggregator.java | 8 +- .../AttributeCollectWithDistinctAggregator.java | 27 +- .../extension/ContainsIgnoreCaseExtension.java | 18 +- .../extension/EqualsIgnoreCaseExtension.java | 22 +- .../RegexpIgnoreCaseFunctionExtension.java | 16 +- .../alert/engine/sorter/BaseStreamWindow.java | 88 +-- .../alert/engine/sorter/StreamTimeClock.java | 13 +- .../engine/sorter/StreamTimeClockListener.java | 3 +- .../engine/sorter/StreamTimeClockManager.java | 15 +- .../engine/sorter/StreamTimeClockTrigger.java | 19 +- .../eagle/alert/engine/sorter/StreamWindow.java | 54 +- .../engine/sorter/StreamWindowManager.java | 23 +- .../engine/sorter/StreamWindowRepository.java | 171 +++-- .../sorter/impl/CachedEventGroupSerializer.java | 31 +- .../impl/PartitionedEventGroupSerializer.java | 45 +- .../PartitionedEventTimeOrderingComparator.java | 18 +- .../impl/StreamSortWindowHandlerImpl.java | 32 +- .../sorter/impl/StreamSortedWindowInMapDB.java | 86 ++- .../sorter/impl/StreamSortedWindowOnHeap.java | 30 +- .../impl/StreamTimeClockInLocalMemory.java | 22 +- .../sorter/impl/StreamTimeClockManagerImpl.java | 73 ++- .../sorter/impl/StreamWindowManagerImpl.java | 47 +- .../alert/engine/spout/CorrelationSpout.java | 98 ++- .../alert/engine/spout/CreateTopicUtils.java | 18 +- .../eagle/alert/engine/spout/ISpoutSpecLCM.java | 9 +- .../engine/spout/KafkaMessageIdWrapper.java | 8 +- .../eagle/alert/engine/spout/SchemeBuilder.java | 10 +- .../spout/SpoutOutputCollectorWrapper.java | 72 +-- .../alert/engine/utils/CompressionUtils.java | 6 +- .../alert/engine/utils/MetadataSerDeser.java | 43 +- .../alert/engine/utils/SerializableUtils.java | 25 +- .../main/java/storm/kafka/KafkaSpoutMetric.java | 23 +- .../java/storm/kafka/KafkaSpoutWrapper.java | 26 +- .../src/main/resources/ALERT_DEFAULT.vm | 488 ++++++++------- .../src/main/resources/application.conf | 32 +- .../src/main/resources/log4j.properties | 3 - .../alert/engine/absence/TestAbsenceDriver.java | 34 +- .../absence/TestAbsencePolicyHandler.java | 14 +- .../absence/TestAbsenceWindowGenerator.java | 16 +- .../absence/TestAbsenceWindowProcessor.java | 4 +- .../alert/engine/e2e/CoordinatorClient.java | 16 +- .../eagle/alert/engine/e2e/Integration1.java | 17 +- .../eagle/alert/engine/e2e/Integration2.java | 55 +- .../eagle/alert/engine/e2e/Integration3.java | 17 +- .../engine/e2e/Integration4NoDataAlert.java | 20 +- .../engine/e2e/Integration5AbsenceAlert.java | 8 +- .../e2e/MetadataServiceClientImpTest.java | 10 +- .../eagle/alert/engine/e2e/SampleClient1.java | 17 +- .../eagle/alert/engine/e2e/SampleClient2.java | 19 +- .../eagle/alert/engine/e2e/SampleClient3.java | 17 +- .../engine/e2e/SampleClient4NoDataAlert.java | 41 +- .../engine/e2e/SampleClient5AbsenceAlert.java | 14 +- ...oltOutputCollectorThreadSafeWrapperTest.java | 49 +- .../engine/evaluator/PoilcyExtendedTest.java | 2 +- .../SiddhiCEPPolicyEventHandlerTest.java | 136 ++-- .../integration/MockMetadataServiceClient.java | 24 +- .../engine/metric/MemoryUsageGaugeSetTest.java | 17 +- .../engine/mock/MockPartitionedCollector.java | 15 +- .../engine/mock/MockSampleMetadataFactory.java | 160 +++-- .../alert/engine/mock/MockStreamCollector.java | 15 +- .../engine/mock/MockStreamMetadataService.java | 18 +- .../alert/engine/mock/MockStreamReceiver.java | 41 +- .../TestDistinctValuesInTimeBatchWindow.java | 86 ++- .../nodata/TestDistinctValuesInTimeWindow.java | 20 +- .../alert/engine/nodata/TestEventTable.java | 16 +- .../alert/engine/nodata/TestNoDataAlert.java | 46 +- .../engine/nodata/TestNoDataPolicyHandler.java | 27 +- .../TestNoDataPolicyTimeBatchHandler.java | 228 +++---- .../alert/engine/perf/TestSerDeserPer.java | 48 +- .../alert/engine/router/TestAlertBolt.java | 102 +-- .../engine/router/TestAlertPublisherBolt.java | 8 +- .../engine/runner/TestStreamRouterBolt.java | 120 ++-- .../serialization/JavaSerializationTest.java | 54 +- .../PartitionedEventSerializerTest.java | 132 ++-- .../alert/engine/siddhi/SiddhiPolicyTest.java | 105 ++-- .../AttributeCollectAggregatorTest.java | 37 +- .../alert/engine/sorter/MapDBTestSuite.java | 20 +- .../engine/sorter/StreamSortHandlerTest.java | 100 ++- .../sorter/StreamWindowBenchmarkTest.java | 104 ++-- .../engine/sorter/StreamWindowTestSuite.java | 93 ++- .../sorter/TreeMultisetComparatorTest.java | 37 +- .../engine/statecheck/TestStateCheckPolicy.java | 11 +- .../engine/topology/AlertTopologyTest.java | 52 +- .../CoordinatorSpoutIntegrationTest.java | 33 +- .../engine/topology/CorrelationSpoutTest.java | 65 +- .../engine/topology/FastWordCountTopology.java | 56 +- .../MockMetadataChangeNotifyService.java | 28 +- .../engine/topology/SendData2KafkaTest.java | 20 +- .../eagle/alert/engine/topology/TestBolt.java | 16 +- .../alert/engine/topology/TestByteBuffer.java | 10 +- .../topology/TestMetadataSpecSerDeser.java | 61 +- .../TestStormCustomGroupingRouting.java | 76 +-- .../engine/topology/TestStormParallelism.java | 57 +- .../topology/TestStormStreamIdRouting.java | 41 +- .../topology/TestTuple2StreamConverter.java | 14 +- .../engine/topology/TestUnitTopologyMain.java | 19 +- .../engine/utils/CompressionUtilsTest.java | 12 +- .../alert/engine/utils/TimePeriodUtilsTest.java | 26 +- .../resources/absence/application-absence.conf | 48 +- .../src/test/resources/absence/datasources.json | 30 +- .../src/test/resources/absence/policies.json | 46 +- .../test/resources/absence/publishments.json | 36 +- .../resources/absence/streamdefinitions.json | 54 +- .../src/test/resources/absence/topologies.json | 58 +- .../test/resources/application-test-backup.conf | 58 +- .../src/test/resources/application-test.conf | 54 +- .../correlation/application-integration-2.conf | 48 +- .../test/resources/correlation/datasources.json | 69 +-- .../test/resources/correlation/policies.json | 74 +-- .../resources/correlation/publishments.json | 32 +- .../correlation/streamdefinitions.json | 181 +++--- .../test/resources/correlation/topologies.json | 58 +- .../test/resources/correlation_spouttest.conf | 42 +- .../src/test/resources/e2e/application-e2e.conf | 48 +- .../src/test/resources/e2e/datasources.json | 36 +- .../src/test/resources/e2e/policies.json | 50 +- .../src/test/resources/e2e/publishments.json | 30 +- .../src/test/resources/e2e/sherlock.json | 3 +- .../test/resources/e2e/streamdefinitions.json | 155 ++--- .../src/test/resources/e2e/topologies.json | 58 +- .../src/test/resources/e2e/ump_demo_schema.json | 321 +++++----- .../src/test/resources/log4j.properties | 3 - .../test/resources/loopback/publishments.json | 27 +- .../resources/loopback/streamdefinitions.json | 140 ++--- .../resources/nodata/application-nodata.conf | 48 +- .../src/test/resources/nodata/datasources.json | 30 +- .../nodata/policies-provided-wisb.json | 42 +- .../src/test/resources/nodata/policies.json | 46 +- .../src/test/resources/nodata/publishments.json | 36 +- .../resources/nodata/streamdefinitions.json | 54 +- .../src/test/resources/nodata/topologies.json | 58 +- .../router/publishments-empty-dedup-field.json | 17 +- .../src/test/resources/router/publishments.json | 43 +- .../src/test/resources/sample_perfmon_data.json | 9 +- .../simple/application-integration.conf | 60 +- .../src/test/resources/simple/datasources.json | 34 +- .../src/test/resources/simple/policies.json | 158 ++--- .../src/test/resources/simple/publishments.json | 59 +- .../resources/simple/streamdefinitions.json | 87 +-- .../src/test/resources/simple/topologies.json | 78 +-- .../statecheck/application-statecheck.conf | 48 +- .../test/resources/statecheck/datasources.json | 34 +- .../test/resources/statecheck/topologies.json | 58 +- .../src/test/resources/testPublishForAdd0.json | 20 +- .../src/test/resources/testPublishForAdd1.json | 32 +- .../test/resources/testPublishForMdyValue.json | 21 +- .../src/test/resources/testPublishSpec.json | 28 +- .../src/test/resources/testPublishSpec2.json | 26 +- .../alert-metadata-service/pom.xml | 12 +- .../metadata/resource/MetadataResource.java | 65 +- .../topology/resource/TopologyMgmtResource.java | 6 +- .../impl/TopologyMgmtResourceHelper.java | 8 +- .../resource/impl/TopologyMgmtResourceImpl.java | 67 +- .../src/test/resources/application.conf | 6 +- .../eagle/alert/metadata/IMetadataDao.java | 8 +- .../eagle/alert/metadata/MetadataUtils.java | 8 +- .../metadata/impl/InMemMetadataDaoImpl.java | 34 +- .../metadata/impl/JdbcDatabaseHandler.java | 32 +- .../metadata/impl/JdbcMetadataDaoImpl.java | 44 +- .../alert/metadata/impl/JdbcSchemaManager.java | 35 +- .../alert/metadata/impl/MetadataDaoFactory.java | 10 +- .../metadata/impl/MongoMetadataDaoImpl.java | 126 ++-- .../eagle/alert/metadata/resource/Models.java | 13 +- .../eagle/alert/metadata/resource/OpResult.java | 3 +- .../alert/resource/impl/InMemoryTest.java | 12 +- .../alert/resource/impl/JdbcImplTest.java | 23 +- .../alert/resource/impl/MongoImplTest.java | 15 +- .../src/test/resources/application-mongo.conf | 8 +- .../src/test/resources/application.conf | 12 +- .../eagle-alert/alert-metadata-parent/pom.xml | 28 +- .../eagle-alert/alert-service/pom.xml | 364 +++++------ .../app/AlertDropWizardConfiguration.java | 3 +- .../apache/eagle/service/app/ServiceApp.java | 24 +- .../src/main/resources/application.conf | 74 +-- .../src/main/resources/log4j.properties | 2 - .../src/main/webapp/WEB-INF/web.xml | 49 +- .../eagle/service/app/TestServiceAppWithZk.java | 162 +++-- eagle-core/eagle-alert-parent/pom.xml | 18 +- 415 files changed, 8790 insertions(+), 8965 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/a0fc8708/eagle-core/eagle-alert-parent/eagle-alert-app/src/main/java/org/apache/eagle/alert/app/AlertUnitTopologyApp.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert-parent/eagle-alert-app/src/main/java/org/apache/eagle/alert/app/AlertUnitTopologyApp.java b/eagle-core/eagle-alert-parent/eagle-alert-app/src/main/java/org/apache/eagle/alert/app/AlertUnitTopologyApp.java index a80c3b8..63e92ff 100644 --- a/eagle-core/eagle-alert-parent/eagle-alert-app/src/main/java/org/apache/eagle/alert/app/AlertUnitTopologyApp.java +++ b/eagle-core/eagle-alert-parent/eagle-alert-app/src/main/java/org/apache/eagle/alert/app/AlertUnitTopologyApp.java @@ -15,12 +15,14 @@ * limitations under the License. */ -package org.apache.eagle.alert.app;import backtype.storm.generated.StormTopology; -import com.typesafe.config.Config; -import com.typesafe.config.ConfigFactory; +package org.apache.eagle.alert.app; + import org.apache.eagle.alert.engine.UnitTopologyMain; import org.apache.eagle.app.StormApplication; import org.apache.eagle.app.environment.impl.StormEnvironment; +import backtype.storm.generated.StormTopology; +import com.typesafe.config.Config; +import com.typesafe.config.ConfigFactory; /** * since 8/25/16. @@ -31,7 +33,7 @@ public class AlertUnitTopologyApp extends StormApplication { return UnitTopologyMain.createTopology(config); } - public static void main(String[] args){ + public static void main(String[] args) { Config config = ConfigFactory.load(); AlertUnitTopologyApp app = new AlertUnitTopologyApp(); app.run(config); http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/a0fc8708/eagle-core/eagle-alert-parent/eagle-alert-service/src/main/java/org/apache/eagle/service/alert/resolver/AttributeResolvable.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert-parent/eagle-alert-service/src/main/java/org/apache/eagle/service/alert/resolver/AttributeResolvable.java b/eagle-core/eagle-alert-parent/eagle-alert-service/src/main/java/org/apache/eagle/service/alert/resolver/AttributeResolvable.java index ecfd47f..86b78c1 100644 --- a/eagle-core/eagle-alert-parent/eagle-alert-service/src/main/java/org/apache/eagle/service/alert/resolver/AttributeResolvable.java +++ b/eagle-core/eagle-alert-parent/eagle-alert-service/src/main/java/org/apache/eagle/service/alert/resolver/AttributeResolvable.java @@ -21,24 +21,24 @@ import java.util.List; /** * @param <R> * @param <V> - * @since 6/16/15 + * @since 6/16/15. */ public interface AttributeResolvable<R extends GenericAttributeResolveRequest, V> { /** - * @param request request type + * @param request request type. * @return List<V> * @throws AttributeResolveException */ List<V> resolve(R request) throws AttributeResolveException; /** - * validate request + * validate request. * @throws BadAttributeResolveRequestException */ void validateRequest(R request) throws BadAttributeResolveRequestException; /** - * @return Class<R> + * @return Class<R>. */ Class<R> getRequestClass(); } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/a0fc8708/eagle-core/eagle-alert-parent/eagle-alert-service/src/main/java/org/apache/eagle/service/alert/resolver/AttributeResolveException.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert-parent/eagle-alert-service/src/main/java/org/apache/eagle/service/alert/resolver/AttributeResolveException.java b/eagle-core/eagle-alert-parent/eagle-alert-service/src/main/java/org/apache/eagle/service/alert/resolver/AttributeResolveException.java index 56cd942..4c4f1dd 100644 --- a/eagle-core/eagle-alert-parent/eagle-alert-service/src/main/java/org/apache/eagle/service/alert/resolver/AttributeResolveException.java +++ b/eagle-core/eagle-alert-parent/eagle-alert-service/src/main/java/org/apache/eagle/service/alert/resolver/AttributeResolveException.java @@ -17,10 +17,18 @@ package org.apache.eagle.service.alert.resolver; /** - * @since 6/16/15 + * @since 6/16/15. */ public class AttributeResolveException extends Exception { - public AttributeResolveException(String s, Exception e) { super(s,e); } - public AttributeResolveException(Exception e) { super(e); } - public AttributeResolveException(String s) { super(s); } + public AttributeResolveException(String s, Exception e) { + super(s, e); + } + + public AttributeResolveException(Exception e) { + super(e); + } + + public AttributeResolveException(String s) { + super(s); + } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/a0fc8708/eagle-core/eagle-alert-parent/eagle-alert-service/src/main/java/org/apache/eagle/service/alert/resolver/AttributeResolveResource.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert-parent/eagle-alert-service/src/main/java/org/apache/eagle/service/alert/resolver/AttributeResolveResource.java b/eagle-core/eagle-alert-parent/eagle-alert-service/src/main/java/org/apache/eagle/service/alert/resolver/AttributeResolveResource.java index 20207ab..9375b6a 100644 --- a/eagle-core/eagle-alert-parent/eagle-alert-service/src/main/java/org/apache/eagle/service/alert/resolver/AttributeResolveResource.java +++ b/eagle-core/eagle-alert-parent/eagle-alert-service/src/main/java/org/apache/eagle/service/alert/resolver/AttributeResolveResource.java @@ -16,18 +16,18 @@ */ package org.apache.eagle.service.alert.resolver; -import com.google.inject.Inject; -import com.typesafe.config.Config; import org.apache.eagle.log.entity.GenericServiceAPIResponseEntity; -import com.fasterxml.jackson.databind.ObjectMapper; import org.apache.eagle.metadata.service.ApplicationEntityService; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.google.inject.Inject; +import com.typesafe.config.Config; -import javax.ws.rs.*; import java.io.InputStream; import java.util.List; +import javax.ws.rs.*; /** - * @since 6/17/15 + * @since 6/17/15. */ @Path("/stream") public class AttributeResolveResource { @@ -35,24 +35,28 @@ public class AttributeResolveResource { private Config eagleServerConfig; @Inject - public AttributeResolveResource(ApplicationEntityService entityService, Config eagleServerConfig){ + public AttributeResolveResource(ApplicationEntityService entityService, Config eagleServerConfig) { this.entityService = entityService; this.eagleServerConfig = eagleServerConfig; } @POST @Path("attributeresolve") - @Consumes({"application/json"}) - @Produces({"application/json"}) + @Consumes( {"application/json"}) + @Produces( {"application/json"}) public GenericServiceAPIResponseEntity attributeResolve(InputStream request, - @QueryParam("resolver") String resolver){ + @QueryParam("resolver") String resolver) { GenericServiceAPIResponseEntity response = new GenericServiceAPIResponseEntity(); try { - if(resolver == null) throw new AttributeResolveException("resolver is null"); + if (resolver == null) { + throw new AttributeResolveException("resolver is null"); + } AttributeResolvable resolvable = AttributeResolverFactory.getAttributeResolver(resolver, entityService, eagleServerConfig); ObjectMapper objectMapper = new ObjectMapper(); Class<?> resolveRequestClass = resolvable.getRequestClass(); - if(resolveRequestClass == null) throw new AttributeResolveException("Request class is null for resolver "+resolver); + if (resolveRequestClass == null) { + throw new AttributeResolveException("Request class is null for resolver " + resolver); + } GenericAttributeResolveRequest resolveRequest = (GenericAttributeResolveRequest) objectMapper.readValue(request, resolvable.getRequestClass()); resolvable.validateRequest(resolveRequest); List result = resolvable.resolve(resolveRequest); @@ -68,16 +72,20 @@ public class AttributeResolveResource { @GET @Path("attributeresolve") - @Produces({"application/json"}) + @Produces( {"application/json"}) public GenericServiceAPIResponseEntity attributeResolver( - @QueryParam("resolver") String resolver, @QueryParam("site") String site, @QueryParam("query") String query){ + @QueryParam("resolver") String resolver, @QueryParam("site") String site, @QueryParam("query") String query) { GenericServiceAPIResponseEntity response = new GenericServiceAPIResponseEntity(); try { - if(resolver == null) throw new AttributeResolveException("resolver is null"); + if (resolver == null) { + throw new AttributeResolveException("resolver is null"); + } AttributeResolvable resolvable = AttributeResolverFactory.getAttributeResolver(resolver, entityService, eagleServerConfig); Class<?> resolveRequestClass = resolvable.getRequestClass(); - if(resolveRequestClass == null) throw new AttributeResolveException("Request class is null for resolver "+resolver); - GenericAttributeResolveRequest resolveRequest = new GenericAttributeResolveRequest(query,site); + if (resolveRequestClass == null) { + throw new AttributeResolveException("Request class is null for resolver " + resolver); + } + GenericAttributeResolveRequest resolveRequest = new GenericAttributeResolveRequest(query, site); resolvable.validateRequest(resolveRequest); List result = resolvable.resolve(resolveRequest); response.setSuccess(true); http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/a0fc8708/eagle-core/eagle-alert-parent/eagle-alert-service/src/main/java/org/apache/eagle/service/alert/resolver/AttributeResolverFactory.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert-parent/eagle-alert-service/src/main/java/org/apache/eagle/service/alert/resolver/AttributeResolverFactory.java b/eagle-core/eagle-alert-parent/eagle-alert-service/src/main/java/org/apache/eagle/service/alert/resolver/AttributeResolverFactory.java index a184aa0..010d8c3 100644 --- a/eagle-core/eagle-alert-parent/eagle-alert-service/src/main/java/org/apache/eagle/service/alert/resolver/AttributeResolverFactory.java +++ b/eagle-core/eagle-alert-parent/eagle-alert-service/src/main/java/org/apache/eagle/service/alert/resolver/AttributeResolverFactory.java @@ -16,36 +16,36 @@ */ package org.apache.eagle.service.alert.resolver; -import com.typesafe.config.Config; import org.apache.eagle.metadata.service.ApplicationEntityService; +import com.typesafe.config.Config; import java.util.Collections; import java.util.HashMap; -import java.util.List; import java.util.Map; /** -* @since 6/16/15 -*/ + * @since 6/16/15. + */ public final class AttributeResolverFactory { - private final static Map<String,AttributeResolvable> fieldResolvableCache = Collections.synchronizedMap(new HashMap<>()); + private static final Map<String, AttributeResolvable> fieldResolvableCache = Collections.synchronizedMap(new HashMap<>()); + public static AttributeResolvable getAttributeResolver(String fieldResolverName, ApplicationEntityService entityService, Config eagleServerConfig) throws AttributeResolveException { AttributeResolvable instance; - if(fieldResolvableCache.containsKey(fieldResolverName)){ + if (fieldResolvableCache.containsKey(fieldResolverName)) { instance = fieldResolvableCache.get(fieldResolverName); } else { try { - instance = (AttributeResolvable) Class.forName(fieldResolverName). - getConstructor(ApplicationEntityService.class, Config.class). - newInstance(entityService, eagleServerConfig); + instance = (AttributeResolvable) Class.forName(fieldResolverName) + .getConstructor(ApplicationEntityService.class, Config.class) + .newInstance(entityService, eagleServerConfig); fieldResolvableCache.put(fieldResolverName, instance); } catch (ClassNotFoundException e) { - throw new AttributeResolveException("Attribute Resolver in type of "+fieldResolverName+" is not found",e); + throw new AttributeResolveException("Attribute Resolver in type of " + fieldResolverName + " is not found", e); } catch (InstantiationException | IllegalAccessException e) { throw new AttributeResolveException(e); - } catch (Exception ex){ + } catch (Exception ex) { throw new AttributeResolveException(ex); } } http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/a0fc8708/eagle-core/eagle-alert-parent/eagle-alert-service/src/main/java/org/apache/eagle/service/alert/resolver/BadAttributeResolveRequestException.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert-parent/eagle-alert-service/src/main/java/org/apache/eagle/service/alert/resolver/BadAttributeResolveRequestException.java b/eagle-core/eagle-alert-parent/eagle-alert-service/src/main/java/org/apache/eagle/service/alert/resolver/BadAttributeResolveRequestException.java index 5a2d7e6..741dd31 100644 --- a/eagle-core/eagle-alert-parent/eagle-alert-service/src/main/java/org/apache/eagle/service/alert/resolver/BadAttributeResolveRequestException.java +++ b/eagle-core/eagle-alert-parent/eagle-alert-service/src/main/java/org/apache/eagle/service/alert/resolver/BadAttributeResolveRequestException.java @@ -17,15 +17,15 @@ package org.apache.eagle.service.alert.resolver; public class BadAttributeResolveRequestException extends Exception { - public BadAttributeResolveRequestException(Exception ex){ + public BadAttributeResolveRequestException(Exception ex) { super(ex); } - public BadAttributeResolveRequestException(String msg){ + public BadAttributeResolveRequestException(String msg) { super(msg); } - public BadAttributeResolveRequestException(String msg, Exception ex){ + public BadAttributeResolveRequestException(String msg, Exception ex) { super(msg, ex); } } http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/a0fc8708/eagle-core/eagle-alert-parent/eagle-alert-service/src/main/java/org/apache/eagle/service/alert/resolver/GenericAttributeResolveRequest.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert-parent/eagle-alert-service/src/main/java/org/apache/eagle/service/alert/resolver/GenericAttributeResolveRequest.java b/eagle-core/eagle-alert-parent/eagle-alert-service/src/main/java/org/apache/eagle/service/alert/resolver/GenericAttributeResolveRequest.java index 97899b7..ee7ac99 100644 --- a/eagle-core/eagle-alert-parent/eagle-alert-service/src/main/java/org/apache/eagle/service/alert/resolver/GenericAttributeResolveRequest.java +++ b/eagle-core/eagle-alert-parent/eagle-alert-service/src/main/java/org/apache/eagle/service/alert/resolver/GenericAttributeResolveRequest.java @@ -20,16 +20,16 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; /** - * @since 6/16/15 + * @since 6/16/15. */ public class GenericAttributeResolveRequest { /** - * @param query whatever is in input box of attribute - * @param site which site this policy belongs to + * @param query whatever is in input box of attribute. + * @param site which site this policy belongs to. */ @JsonCreator - public GenericAttributeResolveRequest(@JsonProperty("query") String query, @JsonProperty("site") String site){ - this.query = query; + public GenericAttributeResolveRequest(@JsonProperty("query") String query, @JsonProperty("site") String site) { + this.query = query; this.site = site; } http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/a0fc8708/eagle-core/eagle-alert-parent/eagle-alert-service/src/main/java/org/apache/eagle/service/alert/resolver/impl/BooleanAttributeResolver.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert-parent/eagle-alert-service/src/main/java/org/apache/eagle/service/alert/resolver/impl/BooleanAttributeResolver.java b/eagle-core/eagle-alert-parent/eagle-alert-service/src/main/java/org/apache/eagle/service/alert/resolver/impl/BooleanAttributeResolver.java index 3dc70e1..72bf056 100644 --- a/eagle-core/eagle-alert-parent/eagle-alert-service/src/main/java/org/apache/eagle/service/alert/resolver/impl/BooleanAttributeResolver.java +++ b/eagle-core/eagle-alert-parent/eagle-alert-service/src/main/java/org/apache/eagle/service/alert/resolver/impl/BooleanAttributeResolver.java @@ -16,15 +16,15 @@ */ package org.apache.eagle.service.alert.resolver.impl; +import org.apache.eagle.service.alert.resolver.AttributeResolvable; import org.apache.eagle.service.alert.resolver.AttributeResolveException; import org.apache.eagle.service.alert.resolver.GenericAttributeResolveRequest; -import org.apache.eagle.service.alert.resolver.AttributeResolvable; import java.util.Arrays; import java.util.List; /** - * @since 6/16/15 + * @since 6/16/15. */ public class BooleanAttributeResolver implements AttributeResolvable<GenericAttributeResolveRequest,String> { @Override http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/a0fc8708/eagle-core/eagle-alert-parent/eagle-alert-service/src/main/java/org/apache/eagle/service/alert/resolver/impl/EntityAttributeResolver.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert-parent/eagle-alert-service/src/main/java/org/apache/eagle/service/alert/resolver/impl/EntityAttributeResolver.java b/eagle-core/eagle-alert-parent/eagle-alert-service/src/main/java/org/apache/eagle/service/alert/resolver/impl/EntityAttributeResolver.java index 9758863..affb54b 100644 --- a/eagle-core/eagle-alert-parent/eagle-alert-service/src/main/java/org/apache/eagle/service/alert/resolver/impl/EntityAttributeResolver.java +++ b/eagle-core/eagle-alert-parent/eagle-alert-service/src/main/java/org/apache/eagle/service/alert/resolver/impl/EntityAttributeResolver.java @@ -16,8 +16,9 @@ */ package org.apache.eagle.service.alert.resolver.impl; -import org.apache.eagle.log.entity.GenericServiceAPIResponseEntity; +import org.apache.eagle.common.DateTimeUtil; import org.apache.eagle.log.base.taggedlog.TaggedLogAPIEntity; +import org.apache.eagle.log.entity.GenericServiceAPIResponseEntity; import org.apache.eagle.log.entity.meta.EntityDefinition; import org.apache.eagle.log.entity.meta.EntityDefinitionManager; import org.apache.eagle.service.alert.resolver.AttributeResolvable; @@ -25,8 +26,6 @@ import org.apache.eagle.service.alert.resolver.AttributeResolveException; import org.apache.eagle.service.alert.resolver.BadAttributeResolveRequestException; import org.apache.eagle.service.alert.resolver.GenericAttributeResolveRequest; import org.apache.eagle.service.generic.GenericEntityServiceResource; -import org.apache.eagle.common.DateTimeUtil; - import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; import org.apache.commons.lang3.StringUtils; @@ -36,42 +35,42 @@ import java.util.List; import java.util.Map; /** - * @since 6/16/15 + * @since 6/16/15. */ -public class EntityAttributeResolver implements AttributeResolvable<EntityAttributeResolver.EntityAttributeResolveRequest,String> { +public class EntityAttributeResolver implements AttributeResolvable<EntityAttributeResolver.EntityAttributeResolveRequest, String> { - private final static GenericEntityServiceResource entityServiceResource = new GenericEntityServiceResource(); + private static final GenericEntityServiceResource entityServiceResource = new GenericEntityServiceResource(); @Override public List<String> resolve(EntityAttributeResolveRequest request) throws AttributeResolveException { - if(request.getFieldName()==null){ + if (request.getFieldName() == null) { throw new AttributeResolveException("fieldName is required"); } String attributeName = request.getFieldName(); EntityDefinition entityDefinition; try { - if(request.getServiceName()!=null){ + if (request.getServiceName() != null) { entityDefinition = EntityDefinitionManager.getEntityByServiceName(request.getServiceName()); - }else if (request.getEntityClassName()!=null){ + } else if (request.getEntityClassName() != null) { Class<? extends TaggedLogAPIEntity> entityClass = (Class<? extends TaggedLogAPIEntity>) Class.forName(request.getEntityClassName()); entityDefinition = EntityDefinitionManager.getEntityDefinitionByEntityClass(entityClass); - }else { + } else { throw new AttributeResolveException("At least serviceName or entityClassName is required, but neither found"); } } catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) { throw new AttributeResolveException(e); } List<String> filterCondition = new ArrayList<>(); - if(request.getTags()!=null){ - for(Map.Entry<String,String> tag:request.getTags().entrySet()) { + if (request.getTags() != null) { + for (Map.Entry<String, String> tag : request.getTags().entrySet()) { filterCondition.add("@" + tag.getKey() + " = \"" + tag.getValue() + "\""); } } - if(request.getQuery() != null) { - filterCondition.add("@" + attributeName + "~= \".*" + request.getQuery()+".*\""); + if (request.getQuery() != null) { + filterCondition.add("@" + attributeName + "~= \".*" + request.getQuery() + ".*\""); } String query = entityDefinition.getService() + "[" + StringUtils.join(filterCondition, " AND ") + "]<@" + attributeName + ">{count}"; - return aggregateQuery(query, DateTimeUtil.millisecondsToHumanDateWithSeconds(0), DateTimeUtil.millisecondsToHumanDateWithSeconds(System.currentTimeMillis()),request.getMetricName()); + return aggregateQuery(query, DateTimeUtil.millisecondsToHumanDateWithSeconds(0), DateTimeUtil.millisecondsToHumanDateWithSeconds(System.currentTimeMillis()), request.getMetricName()); } @Override @@ -84,16 +83,16 @@ public class EntityAttributeResolver implements AttributeResolvable<EntityAttrib } - private List<String> aggregateQuery(String query,String startTime,String endTime,String metricName) throws AttributeResolveException { + private List<String> aggregateQuery(String query, String startTime, String endTime, String metricName) throws AttributeResolveException { List<String> result = new ArrayList<>(); GenericServiceAPIResponseEntity response = entityServiceResource.search(query, startTime, endTime, Integer.MAX_VALUE, null, false, false, 0, Integer.MAX_VALUE, true, 0, metricName, false); - if(response.isSuccess()){ + if (response.isSuccess()) { List objs = response.getObj(); - for(Object item:objs){ + for (Object item : objs) { // TODO: get keys as result throw new IllegalArgumentException("not implemented yet"); } - }else{ + } else { throw new AttributeResolveException(response.getException()); } return result; @@ -103,39 +102,47 @@ public class EntityAttributeResolver implements AttributeResolvable<EntityAttrib public Map<String, String> getTags() { return tags; } + private final Map<String, String> tags; + public String getMetricName() { return metricName; } + private final String metricName; + @JsonCreator public EntityAttributeResolveRequest( - @JsonProperty("query") String query, - @JsonProperty("site") String site, - @JsonProperty("serviceName") String serviceName, - @JsonProperty("entityClassName") String entityClassName, - @JsonProperty("metricName") String metricName, - @JsonProperty("fieldName") String fieldName, - @JsonProperty("tags") Map<String, String> tags - ){ + @JsonProperty("query") String query, + @JsonProperty("site") String site, + @JsonProperty("serviceName") String serviceName, + @JsonProperty("entityClassName") String entityClassName, + @JsonProperty("metricName") String metricName, + @JsonProperty("fieldName") String fieldName, + @JsonProperty("tags") Map<String, String> tags + ) { super(query, site); this.serviceName = serviceName; this.entityClassName = entityClassName; this.fieldName = fieldName; this.metricName = metricName; - this.tags = tags; + this.tags = tags; } private final String serviceName; + public String getEntityClassName() { return entityClassName; } + public String getServiceName() { return serviceName; } + public String getFieldName() { return fieldName; } + private final String entityClassName; private final String fieldName; } http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/a0fc8708/eagle-core/eagle-alert-parent/eagle-alert/alert-common/pom.xml ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert-parent/eagle-alert/alert-common/pom.xml b/eagle-core/eagle-alert-parent/eagle-alert/alert-common/pom.xml index 0fb2bb7..57a0157 100644 --- a/eagle-core/eagle-alert-parent/eagle-alert/alert-common/pom.xml +++ b/eagle-core/eagle-alert-parent/eagle-alert/alert-common/pom.xml @@ -83,8 +83,8 @@ <artifactId>jackson-jaxrs-json-provider</artifactId> </dependency> <!--<dependency>--> - <!--<groupId>org.codehaus.jackson</groupId>--> - <!--<artifactId>jackson-jaxrs</artifactId>--> + <!--<groupId>org.codehaus.jackson</groupId>--> + <!--<artifactId>jackson-jaxrs</artifactId>--> <!--</dependency>--> <dependency> <groupId>joda-time</groupId> http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/a0fc8708/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/java/org/apache/eagle/alert/config/ConfigBusBase.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/java/org/apache/eagle/alert/config/ConfigBusBase.java b/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/java/org/apache/eagle/alert/config/ConfigBusBase.java index 5cedba6..71f1d59 100644 --- a/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/java/org/apache/eagle/alert/config/ConfigBusBase.java +++ b/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/java/org/apache/eagle/alert/config/ConfigBusBase.java @@ -18,41 +18,38 @@ */ package org.apache.eagle.alert.config; -import java.io.Closeable; - import org.apache.curator.framework.CuratorFramework; import org.apache.curator.framework.CuratorFrameworkFactory; import org.apache.curator.retry.RetryNTimes; - +import java.io.Closeable; /** * Abstraction of asynchronized configuration management * This is used for config change notification between processes, without this one process has to pull changes triggered by another process - * - * Config bus is similar to message bus, config change producer can publish config change(message) to config bus, - * while config change consumer can subscribe config change and do business logic in callback + * <p>Config bus is similar to message bus, config change producer can publish config change(message) to config bus, + * while config change consumer can subscribe config change and do business logic in callback + * </p> * 1. use zookeeper as media to notify config consumer of config changes * 2. each type of config is represented by topic * 3. each config change can contain actual value or contain reference Id which consumer uses to retrieve actual value. This mechanism will reduce zookeeper overhed - * */ -public class ConfigBusBase implements Closeable{ +public class ConfigBusBase implements Closeable { protected String zkRoot; protected CuratorFramework curator; public ConfigBusBase(ZKConfig config) { this.zkRoot = config.zkRoot; curator = CuratorFrameworkFactory.newClient( - config.zkQuorum, - config.zkSessionTimeoutMs, - config.connectionTimeoutMs, - new RetryNTimes(config.zkRetryTimes, config.zkRetryInterval) + config.zkQuorum, + config.zkSessionTimeoutMs, + config.connectionTimeoutMs, + new RetryNTimes(config.zkRetryTimes, config.zkRetryInterval) ); curator.start(); } @Override - public void close(){ + public void close() { curator.close(); } } http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/a0fc8708/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/java/org/apache/eagle/alert/config/ConfigBusConsumer.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/java/org/apache/eagle/alert/config/ConfigBusConsumer.java b/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/java/org/apache/eagle/alert/config/ConfigBusConsumer.java index 3db30e5..c2849a2 100644 --- a/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/java/org/apache/eagle/alert/config/ConfigBusConsumer.java +++ b/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/java/org/apache/eagle/alert/config/ConfigBusConsumer.java @@ -22,8 +22,7 @@ import org.slf4j.Logger; /** * 1. When consumer is started, it always get notified of config - * 2. When config is changed, consumer always get notified of config change - * + * 2. When config is changed, consumer always get notified of config change. * Reliability issue: * TODO How to ensure config change message is always delivered to consumer */ @@ -31,12 +30,13 @@ public class ConfigBusConsumer extends ConfigBusBase { private static final Logger LOG = org.slf4j.LoggerFactory.getLogger(ConfigBusConsumer.class); private NodeCache cache; + public ConfigBusConsumer(ZKConfig config, String topic, ConfigChangeCallback callback) { super(config); String zkPath = zkRoot + "/" + topic; LOG.info("monitor change for zkPath " + zkPath); cache = new NodeCache(curator, zkPath); - cache.getListenable().addListener( () -> { + cache.getListenable().addListener(() -> { // get node value and notify callback byte[] value = curator.getData().forPath(zkPath); ObjectMapper mapper = new ObjectMapper(); @@ -46,7 +46,7 @@ public class ConfigBusConsumer extends ConfigBusBase { ); try { cache.start(); - } catch(Exception ex) { + } catch (Exception ex) { LOG.error("error start NodeCache listener", ex); throw new RuntimeException(ex); } http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/a0fc8708/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/java/org/apache/eagle/alert/config/ConfigBusProducer.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/java/org/apache/eagle/alert/config/ConfigBusProducer.java b/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/java/org/apache/eagle/alert/config/ConfigBusProducer.java index c2b0165..8f30e5c 100644 --- a/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/java/org/apache/eagle/alert/config/ConfigBusProducer.java +++ b/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/java/org/apache/eagle/alert/config/ConfigBusProducer.java @@ -16,36 +16,31 @@ */ package org.apache.eagle.alert.config; +import com.fasterxml.jackson.databind.ObjectMapper; import org.apache.zookeeper.CreateMode; import org.slf4j.Logger; -import com.fasterxml.jackson.databind.ObjectMapper; - public class ConfigBusProducer extends ConfigBusBase { private static final Logger LOG = org.slf4j.LoggerFactory.getLogger(ConfigBusProducer.class); - public ConfigBusProducer(ZKConfig config){ + public ConfigBusProducer(ZKConfig config) { super(config); } - /** - * @param topic - * @param config - */ - public void send(String topic, ConfigValue config){ + public void send(String topic, ConfigValue config) { // check if topic exists, create this topic if not existing String zkPath = zkRoot + "/" + topic; try { if (curator.checkExists().forPath(zkPath) == null) { curator.create() - .creatingParentsIfNeeded() - .withMode(CreateMode.PERSISTENT) - .forPath(zkPath); + .creatingParentsIfNeeded() + .withMode(CreateMode.PERSISTENT) + .forPath(zkPath); } ObjectMapper mapper = new ObjectMapper(); byte[] content = mapper.writeValueAsBytes(config); curator.setData().forPath(zkPath, content); - }catch(Exception ex){ + } catch (Exception ex) { LOG.error("error creating zkPath " + zkPath, ex); throw new RuntimeException(ex); } http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/a0fc8708/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/java/org/apache/eagle/alert/config/ConfigValue.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/java/org/apache/eagle/alert/config/ConfigValue.java b/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/java/org/apache/eagle/alert/config/ConfigValue.java index f47e1be..b4d6fc3 100644 --- a/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/java/org/apache/eagle/alert/config/ConfigValue.java +++ b/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/java/org/apache/eagle/alert/config/ConfigValue.java @@ -23,7 +23,7 @@ package org.apache.eagle.alert.config; * Config body contains actual data for one topic * this is serialized with json format into zookeeper * value can be versionId which is used for referencing outside data - * or value can be actual config value + * or value can be actual config value. */ public class ConfigValue { private boolean isValueVersionId; @@ -45,7 +45,7 @@ public class ConfigValue { this.value = value; } - public String toString(){ + public String toString() { return "isValueVersionId: " + isValueVersionId + ", value: " + value; } } http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/a0fc8708/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/java/org/apache/eagle/alert/config/ZKConfig.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/java/org/apache/eagle/alert/config/ZKConfig.java b/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/java/org/apache/eagle/alert/config/ZKConfig.java index 086210a..5e0c952 100644 --- a/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/java/org/apache/eagle/alert/config/ZKConfig.java +++ b/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/java/org/apache/eagle/alert/config/ZKConfig.java @@ -21,9 +21,9 @@ package org.apache.eagle.alert.config; import java.io.Serializable; /** - * Memory representation of key zookeeper configurations + * Memory representation of key zookeeper configurations. */ -public class ZKConfig implements Serializable{ +public class ZKConfig implements Serializable { private static final long serialVersionUID = -1287231022807492775L; public String zkQuorum; http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/a0fc8708/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/java/org/apache/eagle/alert/config/ZKConfigBuilder.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/java/org/apache/eagle/alert/config/ZKConfigBuilder.java b/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/java/org/apache/eagle/alert/config/ZKConfigBuilder.java index d7b3232..97c0797 100644 --- a/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/java/org/apache/eagle/alert/config/ZKConfigBuilder.java +++ b/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/java/org/apache/eagle/alert/config/ZKConfigBuilder.java @@ -25,7 +25,7 @@ import com.typesafe.config.Config; * Since 4/28/16. */ public class ZKConfigBuilder { - public static ZKConfig getZKConfig(Config config){ + public static ZKConfig getZKConfig(Config config) { ZKConfig zkConfig = new ZKConfig(); zkConfig.zkQuorum = config.getString("zkConfig.zkQuorum"); zkConfig.zkRoot = config.getString("zkConfig.zkRoot"); http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/a0fc8708/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/java/org/apache/eagle/alert/coordination/model/AlertBoltSpec.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/java/org/apache/eagle/alert/coordination/model/AlertBoltSpec.java b/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/java/org/apache/eagle/alert/coordination/model/AlertBoltSpec.java index 83d307c..b3adda5 100644 --- a/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/java/org/apache/eagle/alert/coordination/model/AlertBoltSpec.java +++ b/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/java/org/apache/eagle/alert/coordination/model/AlertBoltSpec.java @@ -16,18 +16,17 @@ */ package org.apache.eagle.alert.coordination.model; +import org.apache.eagle.alert.engine.coordinator.PolicyDefinition; + +import com.fasterxml.jackson.annotation.JsonIgnore; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; -import org.apache.eagle.alert.engine.coordinator.PolicyDefinition; - -import com.fasterxml.jackson.annotation.JsonIgnore; - /** * The alert specification for topology bolts. - * + * * @since Apr 29, 2016 */ public class AlertBoltSpec { @@ -64,19 +63,19 @@ public class AlertBoltSpec { this.topologyName = topologyName; } -// public List<PolicyDefinition> getBoltPolicy(String boltId) { -// return boltPoliciesMap.get(boltId); -// } -// -// public void addBoltPolicy(String boltId, PolicyDefinition pd) { -// if (boltPoliciesMap.containsKey(boltId)) { -// boltPoliciesMap.get(boltId).add(pd); -// } else { -// List<PolicyDefinition> list = new ArrayList<PolicyDefinition>(); -// boltPoliciesMap.put(boltId, list); -// list.add(pd); -// } -// } + // public List<PolicyDefinition> getBoltPolicy(String boltId) { + // return boltPoliciesMap.get(boltId); + // } + // + // public void addBoltPolicy(String boltId, PolicyDefinition pd) { + // if (boltPoliciesMap.containsKey(boltId)) { + // boltPoliciesMap.get(boltId).add(pd); + // } else { + // List<PolicyDefinition> list = new ArrayList<PolicyDefinition>(); + // boltPoliciesMap.put(boltId, list); + // list.add(pd); + // } + // } public void addBoltPolicy(String boltId, String policyName) { if (boltPolicyIdsMap.containsKey(boltId)) { http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/a0fc8708/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/java/org/apache/eagle/alert/coordination/model/Kafka2TupleMetadata.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/java/org/apache/eagle/alert/coordination/model/Kafka2TupleMetadata.java b/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/java/org/apache/eagle/alert/coordination/model/Kafka2TupleMetadata.java index 6c4f576..e3ec774 100644 --- a/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/java/org/apache/eagle/alert/coordination/model/Kafka2TupleMetadata.java +++ b/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/java/org/apache/eagle/alert/coordination/model/Kafka2TupleMetadata.java @@ -16,15 +16,13 @@ */ package org.apache.eagle.alert.coordination.model; -import java.util.Map; - -import org.apache.commons.lang3.builder.HashCodeBuilder; - import com.google.common.base.Objects; +import org.apache.commons.lang3.builder.HashCodeBuilder; +import java.util.Map; /** + * This metadata model controls how to convert kafka topic into tuple stream. * @since Apr 5, 2016 - * this metadata model controls how to convert kafka topic into tuple stream */ public class Kafka2TupleMetadata { private String type; @@ -78,6 +76,7 @@ public class Kafka2TupleMetadata { public String getTopic() { return this.topic; } + public String getSchemeCls() { return this.schemeCls; } http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/a0fc8708/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/java/org/apache/eagle/alert/coordination/model/PolicyWorkerQueue.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/java/org/apache/eagle/alert/coordination/model/PolicyWorkerQueue.java b/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/java/org/apache/eagle/alert/coordination/model/PolicyWorkerQueue.java index e32d13c..44fad90 100644 --- a/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/java/org/apache/eagle/alert/coordination/model/PolicyWorkerQueue.java +++ b/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/java/org/apache/eagle/alert/coordination/model/PolicyWorkerQueue.java @@ -16,31 +16,14 @@ */ package org.apache.eagle.alert.coordination.model; -import java.util.ArrayList; -import java.util.List; -import java.util.Objects; - +import org.apache.eagle.alert.engine.coordinator.StreamPartition; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.builder.HashCodeBuilder; -import org.apache.eagle.alert.engine.coordinator.StreamPartition; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with this - * work for additional information regarding copyright ownership. The ASF - * licenses this file to You under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * <p/> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p/> - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ public class PolicyWorkerQueue { private StreamPartition partition; @@ -85,8 +68,8 @@ public class PolicyWorkerQueue { return false; } PolicyWorkerQueue that = (PolicyWorkerQueue) other; - return Objects.equals(partition, that.partition) && - CollectionUtils.isEqualCollection(workers, that.workers); + return Objects.equals(partition, that.partition) + && CollectionUtils.isEqualCollection(workers, that.workers); } @Override http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/a0fc8708/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/java/org/apache/eagle/alert/coordination/model/PublishSpec.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/java/org/apache/eagle/alert/coordination/model/PublishSpec.java b/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/java/org/apache/eagle/alert/coordination/model/PublishSpec.java index 06e819a..c1f9b24 100644 --- a/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/java/org/apache/eagle/alert/coordination/model/PublishSpec.java +++ b/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/java/org/apache/eagle/alert/coordination/model/PublishSpec.java @@ -16,16 +16,10 @@ */ package org.apache.eagle.alert.coordination.model; +import org.apache.eagle.alert.engine.coordinator.Publishment; import java.util.ArrayList; import java.util.List; -import org.apache.eagle.alert.engine.coordinator.Publishment; - -/** - * - * @since May 1, 2016 - * - */ public class PublishSpec { private String topologyName; http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/a0fc8708/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/java/org/apache/eagle/alert/coordination/model/RouterSpec.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/java/org/apache/eagle/alert/coordination/model/RouterSpec.java b/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/java/org/apache/eagle/alert/coordination/model/RouterSpec.java index 9a576a3..fc13c56 100644 --- a/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/java/org/apache/eagle/alert/coordination/model/RouterSpec.java +++ b/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/java/org/apache/eagle/alert/coordination/model/RouterSpec.java @@ -22,10 +22,6 @@ import java.util.ArrayList; import java.util.List; -/** - * @since Apr 29, 2016 - * - */ public class RouterSpec { private String version; private String topologyName; http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/a0fc8708/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/java/org/apache/eagle/alert/coordination/model/ScheduleState.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/java/org/apache/eagle/alert/coordination/model/ScheduleState.java b/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/java/org/apache/eagle/alert/coordination/model/ScheduleState.java index 93d038f..40ac85d 100644 --- a/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/java/org/apache/eagle/alert/coordination/model/ScheduleState.java +++ b/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/java/org/apache/eagle/alert/coordination/model/ScheduleState.java @@ -14,8 +14,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.apache.eagle.alert.coordination.model; +import org.apache.eagle.alert.coordination.model.internal.MonitoredStream; +import org.apache.eagle.alert.coordination.model.internal.PolicyAssignment; +import org.apache.eagle.alert.engine.coordinator.PolicyDefinition; +import org.apache.eagle.alert.engine.coordinator.StreamDefinition; import java.util.ArrayList; import java.util.Collection; import java.util.Date; @@ -23,11 +28,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import org.apache.eagle.alert.coordination.model.internal.MonitoredStream; -import org.apache.eagle.alert.coordination.model.internal.PolicyAssignment; -import org.apache.eagle.alert.engine.coordinator.PolicyDefinition; -import org.apache.eagle.alert.engine.coordinator.StreamDefinition; - /** * A global wise of schedule status <br/> * <br/> @@ -36,10 +36,8 @@ import org.apache.eagle.alert.engine.coordinator.StreamDefinition; * <br/> * The solution is in metadata resource, have specs/monitoredStreams/policy * assignments stored in different table/collections with tage version. - * - * - * @since Apr 26, 2016 * + * @since Apr 26, 2016 */ public class ScheduleState { @@ -68,15 +66,15 @@ public class ScheduleState { this.generateTime = String.valueOf(new Date().getTime()); } - public ScheduleState(String version, - Map<String, SpoutSpec> topoSpoutSpecsMap, - Map<String, RouterSpec> groupSpecsMap, - Map<String, AlertBoltSpec> alertSpecsMap, - Map<String, PublishSpec> pubMap, - Collection<PolicyAssignment> assignments, - Collection<MonitoredStream> monitoredStreams, - Collection<PolicyDefinition> definitions, - Collection<StreamDefinition> streams) { + public ScheduleState(String version, + Map<String, SpoutSpec> topoSpoutSpecsMap, + Map<String, RouterSpec> groupSpecsMap, + Map<String, AlertBoltSpec> alertSpecsMap, + Map<String, PublishSpec> pubMap, + Collection<PolicyAssignment> assignments, + Collection<MonitoredStream> monitoredStreams, + Collection<PolicyDefinition> definitions, + Collection<StreamDefinition> streams) { this.spoutSpecs = topoSpoutSpecsMap; this.groupSpecs = groupSpecsMap; this.alertSpecs = alertSpecsMap; @@ -113,7 +111,7 @@ public class ScheduleState { for (PolicyDefinition def : definitions) { this.policySnapshots.add(new VersionedPolicyDefinition(version, def)); } - for (StreamDefinition sd :streams) { + for (StreamDefinition sd : streams) { this.streamSnapshots.add(new VersionedStreamDefinition(version, sd)); } } http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/a0fc8708/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/java/org/apache/eagle/alert/coordination/model/SpoutSpec.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/java/org/apache/eagle/alert/coordination/model/SpoutSpec.java b/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/java/org/apache/eagle/alert/coordination/model/SpoutSpec.java index c0e8ec1..f5c7399 100644 --- a/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/java/org/apache/eagle/alert/coordination/model/SpoutSpec.java +++ b/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/java/org/apache/eagle/alert/coordination/model/SpoutSpec.java @@ -23,19 +23,18 @@ import java.util.List; import java.util.Map; import java.util.Optional; - /** * SpoutSpec metadata control 3 phases for data transformation for one specific topic * phase 1: kafka topic to tuple, controlled by Kafka2TupleMetadata, i.e. Scheme * phase 2: tuple to stream, controlled by Tuple2StreamMetadata, i.e. stream name selector etc. * phase 3: stream repartition, controlled by StreamRepartitionMetadata, i.e. groupby spec - * @since Apr 18, 2016 * + * @since Apr 18, 2016 */ public class SpoutSpec { private String version; -// private String spoutId; + // private String spoutId; private String topologyId; // topicName -> kafka2TupleMetadata @@ -45,27 +44,28 @@ public class SpoutSpec { // topicName -> list of StreamRepartitionMetadata, here it is list because one topic(data source) may spawn multiple streams. private Map<String, List<StreamRepartitionMetadata>> streamRepartitionMetadataMap = new HashMap<String, List<StreamRepartitionMetadata>>(); - public SpoutSpec(){} + public SpoutSpec() { + } public SpoutSpec( - String topologyId, -// String spoutId, - Map<String, List<StreamRepartitionMetadata>> streamRepartitionMetadataMap, - Map<String, Tuple2StreamMetadata> tuple2StreamMetadataMap, - Map<String, Kafka2TupleMetadata> kafka2TupleMetadataMap) { + String topologyId, + // String spoutId, + Map<String, List<StreamRepartitionMetadata>> streamRepartitionMetadataMap, + Map<String, Tuple2StreamMetadata> tuple2StreamMetadataMap, + Map<String, Kafka2TupleMetadata> kafka2TupleMetadataMap) { this.topologyId = topologyId; -// this.spoutId = spoutId; + // this.spoutId = spoutId; this.streamRepartitionMetadataMap = streamRepartitionMetadataMap; this.tuple2StreamMetadataMap = tuple2StreamMetadataMap; this.kafka2TupleMetadataMap = kafka2TupleMetadataMap; } -// public String getSpoutId() { -// return spoutId; -// } -// public void setSpoutId(String spoutId) { -// this.spoutId = spoutId; -// } + // public String getSpoutId() { + // return spoutId; + // } + // public void setSpoutId(String spoutId) { + // this.spoutId = spoutId; + // } public String getTopologyId() { return topologyId; @@ -75,7 +75,7 @@ public class SpoutSpec { return streamRepartitionMetadataMap; } - public Map<String, Tuple2StreamMetadata> getTuple2StreamMetadataMap(){ + public Map<String, Tuple2StreamMetadata> getTuple2StreamMetadataMap() { return this.tuple2StreamMetadataMap; } http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/a0fc8708/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/java/org/apache/eagle/alert/coordination/model/StreamNameSelector.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/java/org/apache/eagle/alert/coordination/model/StreamNameSelector.java b/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/java/org/apache/eagle/alert/coordination/model/StreamNameSelector.java index bc7952c..f613b11 100644 --- a/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/java/org/apache/eagle/alert/coordination/model/StreamNameSelector.java +++ b/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/java/org/apache/eagle/alert/coordination/model/StreamNameSelector.java @@ -19,13 +19,11 @@ package org.apache.eagle.alert.coordination.model; import java.util.Map; /** - * This metadata controls how to figure out stream name from incoming tuple + * This metadata controls how to figure out stream name from incoming tuple. */ public interface StreamNameSelector { /** - * field name to value mapping - * @param tuple - * @return + * field name to value mapping. */ String getStreamName(Map<String, Object> tuple); } http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/a0fc8708/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/java/org/apache/eagle/alert/coordination/model/StreamRepartitionMetadata.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/java/org/apache/eagle/alert/coordination/model/StreamRepartitionMetadata.java b/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/java/org/apache/eagle/alert/coordination/model/StreamRepartitionMetadata.java index 86b1d27..d1ce9da 100644 --- a/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/java/org/apache/eagle/alert/coordination/model/StreamRepartitionMetadata.java +++ b/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/java/org/apache/eagle/alert/coordination/model/StreamRepartitionMetadata.java @@ -21,20 +21,20 @@ import com.fasterxml.jackson.annotation.JsonIgnore; import java.util.ArrayList; import java.util.List; - /** + * This meta-data controls how tuple streamId is repartitioned. * @since Apr 25, 2016 - * This meta-data controls how tuple streamId is repartitioned */ public class StreamRepartitionMetadata { private String topicName; private String streamId; /** - * each stream may have multiple different grouping strategies,for example groupby some fields or even shuffling + * each stream may have multiple different grouping strategies,for example groupby some fields or even shuffling. */ public List<StreamRepartitionStrategy> groupingStrategies = new ArrayList<StreamRepartitionStrategy>(); - public StreamRepartitionMetadata(){} + public StreamRepartitionMetadata() { + } public StreamRepartitionMetadata(String topicName, String stream) { this.topicName = topicName; @@ -44,6 +44,7 @@ public class StreamRepartitionMetadata { public String getStreamId() { return streamId; } + public void setStreamId(String streamId) { this.streamId = streamId; } @@ -51,6 +52,7 @@ public class StreamRepartitionMetadata { public String getTopicName() { return topicName; } + public void setTopicName(String topicName) { this.topicName = topicName; } http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/a0fc8708/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/java/org/apache/eagle/alert/coordination/model/StreamRepartitionStrategy.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/java/org/apache/eagle/alert/coordination/model/StreamRepartitionStrategy.java b/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/java/org/apache/eagle/alert/coordination/model/StreamRepartitionStrategy.java index 203114e..118347f 100644 --- a/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/java/org/apache/eagle/alert/coordination/model/StreamRepartitionStrategy.java +++ b/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/java/org/apache/eagle/alert/coordination/model/StreamRepartitionStrategy.java @@ -16,19 +16,19 @@ */ package org.apache.eagle.alert.coordination.model; -import java.util.ArrayList; -import java.util.List; +import org.apache.eagle.alert.engine.coordinator.StreamPartition; import org.apache.commons.collections.CollectionUtils; -import org.apache.eagle.alert.engine.coordinator.StreamPartition; +import java.util.ArrayList; +import java.util.List; public class StreamRepartitionStrategy { - public StreamPartition partition ; + public StreamPartition partition; public int numTotalParticipatingRouterBolts = 0; // how many group-by bolts participate policy evaluation public int startSequence = 0; // what is the sequence for the first bolt in this topology among all bolts public List<String> totalTargetBoltIds = new ArrayList<String>(); - + public int hashCode() { int hashcode = 1 * 31; hashcode += partition.hashCode(); @@ -37,14 +37,14 @@ public class StreamRepartitionStrategy { } return hashcode; } - + public boolean equals(Object obj) { if (!(obj instanceof StreamRepartitionStrategy)) { return false; } StreamRepartitionStrategy o = (StreamRepartitionStrategy) obj; return partition.equals(o.partition) - && CollectionUtils.isEqualCollection(totalTargetBoltIds, o.totalTargetBoltIds); + && CollectionUtils.isEqualCollection(totalTargetBoltIds, o.totalTargetBoltIds); } public StreamPartition getPartition() { http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/a0fc8708/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/java/org/apache/eagle/alert/coordination/model/StreamRouterSpec.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/java/org/apache/eagle/alert/coordination/model/StreamRouterSpec.java b/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/java/org/apache/eagle/alert/coordination/model/StreamRouterSpec.java index 195c8d9..96dfc59 100644 --- a/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/java/org/apache/eagle/alert/coordination/model/StreamRouterSpec.java +++ b/eagle-core/eagle-alert-parent/eagle-alert/alert-common/src/main/java/org/apache/eagle/alert/coordination/model/StreamRouterSpec.java @@ -16,24 +16,23 @@ */ package org.apache.eagle.alert.coordination.model; +import org.apache.eagle.alert.engine.coordinator.StreamPartition; +import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.lang3.builder.HashCodeBuilder; import java.util.ArrayList; import java.util.List; import java.util.Objects; -import org.apache.commons.collections.CollectionUtils; -import org.apache.commons.lang3.builder.HashCodeBuilder; -import org.apache.eagle.alert.engine.coordinator.StreamPartition; - /** * One RouteSpec means one rule mapping [streamId -> StreamPartition -> * PolicyExecutionQueue] * - * Key is StreamPartition + * <p>Key is StreamPartition. */ public class StreamRouterSpec { private String streamId; private StreamPartition partition; // The meta-data to build - // StreamPartitioner + // StreamPartitioner private List<PolicyWorkerQueue> targetQueue = new ArrayList<PolicyWorkerQueue>(); public StreamPartition getPartition() { @@ -72,7 +71,7 @@ public class StreamRouterSpec { @Override public String toString() { return String.format("StreamRouterSpec[streamId=%s,partition=%s, queue=[%s]]", this.getStreamId(), - this.getPartition(), this.getTargetQueue()); + this.getPartition(), this.getTargetQueue()); } @Override @@ -84,8 +83,8 @@ public class StreamRouterSpec { return false; } StreamRouterSpec that = (StreamRouterSpec) other; - return Objects.equals(streamId, that.streamId) && - Objects.equals(partition, that.partition) && - CollectionUtils.isEqualCollection(targetQueue, that.targetQueue); + return Objects.equals(streamId, that.streamId) + && Objects.equals(partition, that.partition) + && CollectionUtils.isEqualCollection(targetQueue, that.targetQueue); } } \ No newline at end of file