http://git-wip-us.apache.org/repos/asf/eagle/blob/6fd95d5c/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/main/java/org/apache/eagle/alert/engine/spout/SpoutOutputCollectorWrapper.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/main/java/org/apache/eagle/alert/engine/spout/SpoutOutputCollectorWrapper.java b/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/main/java/org/apache/eagle/alert/engine/spout/SpoutOutputCollectorWrapper.java deleted file mode 100644 index 1036a36..0000000 --- a/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/main/java/org/apache/eagle/alert/engine/spout/SpoutOutputCollectorWrapper.java +++ /dev/null @@ -1,229 +0,0 @@ -/* - * - * * 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 - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * 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. - * - */ -package org.apache.eagle.alert.engine.spout; - -import backtype.storm.spout.ISpoutOutputCollector; -import backtype.storm.spout.SpoutOutputCollector; -import org.apache.commons.lang3.builder.HashCodeBuilder; -import org.apache.eagle.alert.coordination.model.SpoutSpec; -import org.apache.eagle.alert.coordination.model.StreamRepartitionMetadata; -import org.apache.eagle.alert.coordination.model.StreamRepartitionStrategy; -import org.apache.eagle.alert.coordination.model.Tuple2StreamConverter; -import org.apache.eagle.alert.engine.coordinator.StreamDefinition; -import org.apache.eagle.alert.engine.coordinator.StreamPartition; -import org.apache.eagle.alert.engine.model.PartitionedEvent; -import org.apache.eagle.alert.engine.model.StreamEvent; -import org.apache.eagle.alert.engine.serialization.PartitionedEventSerializer; -import org.apache.eagle.alert.engine.serialization.SerializationMetadataProvider; -import org.apache.eagle.alert.utils.StreamIdConversion; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.Collections; -import java.util.List; -import java.util.Map; - -/** - * intercept the message sent from within KafkaSpout and select downstream bolts based on meta-data - * This is topic based. each topic will have one SpoutOutputCollectorWrapper. - */ -public class SpoutOutputCollectorWrapper extends SpoutOutputCollector implements ISpoutSpecLCM, SerializationMetadataProvider { - private static final Logger LOG = LoggerFactory.getLogger(SpoutOutputCollectorWrapper.class); - - private final ISpoutOutputCollector delegate; - private final String topic; - private final PartitionedEventSerializer serializer; - private int numOfRouterBolts; - private boolean logEventEnabled; - - private volatile List<StreamRepartitionMetadata> streamRepartitionMetadataList; - private volatile Tuple2StreamConverter converter; - private CorrelationSpout spout; - private volatile Map<String, StreamDefinition> sds; - - /** - * @param delegate actual SpoutOutputCollector to send data to following bolts - * @param topic topic for this KafkaSpout to handle - * @param numGroupbyBolts bolts following this spout. - * @param serializer - */ - public SpoutOutputCollectorWrapper(CorrelationSpout spout, - ISpoutOutputCollector delegate, - String topic, - SpoutSpec spoutSpec, - int numGroupbyBolts, - Map<String, StreamDefinition> sds, PartitionedEventSerializer serializer, boolean logEventEnabled) { - super(delegate); - this.spout = spout; - this.delegate = delegate; - this.topic = topic; - this.streamRepartitionMetadataList = spoutSpec.getStreamRepartitionMetadataMap().get(topic); - this.converter = new Tuple2StreamConverter(spoutSpec.getTuple2StreamMetadataMap().get(topic)); - this.numOfRouterBolts = numGroupbyBolts; - this.sds = sds; - this.serializer = serializer; - this.logEventEnabled = logEventEnabled; - } - - /** - * How to assert that numTotalGroupbyBolts >= numOfRouterBolts, otherwise - * there is runtime issue by default, tuple includes 2 fields field 1: topic - * name field 2: map of key/value. - */ - @SuppressWarnings("rawtypes") - @Override - public List<Integer> emit(List<Object> tuple, Object messageId) { - if (!sanityCheck()) { - LOG.error( - "spout collector for topic {} see monitored metadata invalid, is this data source removed! Trigger message id {} ", - topic, messageId); - return null; - } - - KafkaMessageIdWrapper newMessageId = new KafkaMessageIdWrapper(messageId); - newMessageId.topic = topic; - newMessageId.timestamp = System.currentTimeMillis(); - /** - phase 1: tuple to stream converter - if this topic multiplexes multiple streams, then retrieve the individual streams. - */ - List<Object> convertedTuple = converter.convert(tuple); - if (convertedTuple == null) { - LOG.debug("source data {} can't be converted to a stream, ignore this message", tuple); - spout.ack(newMessageId); - return null; - } - Map m = (Map) convertedTuple.get(3); - Object streamId = convertedTuple.get(1); - - StreamDefinition sd = sds.get(streamId); - if (sd == null) { - LOG.warn("StreamDefinition {} is not found within {}, ignore this message", streamId, sds); - spout.ack(newMessageId); - return null; - } - - StreamEvent event = convertToStreamEventByStreamDefinition((Long) convertedTuple.get(2), m, sds.get(streamId)); - if (logEventEnabled) { - LOG.info("Spout from topic {} emit event: {}", topic, event); - } - - /* - phase 2: stream repartition - */ - for (StreamRepartitionMetadata md : streamRepartitionMetadataList) { - if (!event.getStreamId().equals(md.getStreamId())) { - continue; - } - // one stream may have multiple group-by strategies, each strategy is for a specific group-by - for (StreamRepartitionStrategy groupingStrategy : md.groupingStrategies) { - int hash = 0; - if (groupingStrategy.getPartition().getType().equals(StreamPartition.Type.GROUPBY)) { - hash = getRoutingHashByGroupingStrategy(m, groupingStrategy); - } else if (groupingStrategy.getPartition().getType().equals(StreamPartition.Type.SHUFFLE)) { - hash = Math.abs((int) System.currentTimeMillis()); - } - int mod = hash % groupingStrategy.numTotalParticipatingRouterBolts; - // filter out message - if (mod >= groupingStrategy.startSequence && mod < groupingStrategy.startSequence + numOfRouterBolts) { - // framework takes care of field grouping instead of using storm internal field grouping - String sid = StreamIdConversion.generateStreamIdBetween(spout.getSpoutName(), spout.getRouteBoltName() + (hash % numOfRouterBolts)); - if (LOG.isDebugEnabled()) { - LOG.debug("Emitted tuple: {} with message Id: {}, with topic {}, to streamId {}", convertedTuple, messageId, topic, sid); - } - // send message to StreamRouterBolt - PartitionedEvent pEvent = new PartitionedEvent(event, groupingStrategy.partition, hash); - if (this.serializer == null) { - delegate.emit(sid, Collections.singletonList(pEvent), newMessageId); - } else { - try { - delegate.emit(sid, Collections.singletonList(serializer.serialize(pEvent)), newMessageId); - } catch (Exception e) { - LOG.error("Failed to serialize {}, this message would be ignored!", pEvent, e); - spout.ack(newMessageId); - } - } - } else { - // ******* short-cut ack ******** - // we should simply ack those messages which are not processed in this topology because KafkaSpout implementation requires _pending is empty - // before moving to next offsets. - if (LOG.isDebugEnabled()) { - LOG.debug("Message filtered with mod {} not within range {} and {} for message {}", mod, groupingStrategy.startSequence, - groupingStrategy.startSequence + numOfRouterBolts, tuple); - } - spout.ack(newMessageId); - } - } - } - - return null; - } - - @SuppressWarnings("rawtypes") - private int getRoutingHashByGroupingStrategy(Map data, StreamRepartitionStrategy gs) { - // calculate hash value for values from group-by fields - HashCodeBuilder hashCodeBuilder = new HashCodeBuilder(); - for (String groupingField : gs.partition.getColumns()) { - if (data.get(groupingField) != null) { - hashCodeBuilder.append(data.get(groupingField)); - } else { - LOG.warn("Required GroupBy fields {} not found: {}", gs.partition.getColumns(), data); - } - } - int hash = hashCodeBuilder.toHashCode(); - hash = Math.abs(hash); - return hash; - } - - private boolean sanityCheck() { - boolean isOk = true; - if (streamRepartitionMetadataList == null) { - LOG.error("streamRepartitionMetadataList is null!"); - isOk = false; - } - if (converter == null) { - LOG.error("tuple2StreamMetadata is null!"); - isOk = false; - } - return isOk; - } - - @SuppressWarnings( {"rawtypes", "unchecked"}) - private StreamEvent convertToStreamEventByStreamDefinition(long timestamp, Map m, StreamDefinition sd) { - return StreamEvent.builder().timestamep(timestamp).attributes(m, sd).build(); - } - - /** - * SpoutSpec may be changed, this class will respond to changes on tuple2StreamMetadataMap and streamRepartitionMetadataMap. - * - * @param spoutSpec - * @param sds - */ - @Override - public void update(SpoutSpec spoutSpec, Map<String, StreamDefinition> sds) { - this.streamRepartitionMetadataList = spoutSpec.getStreamRepartitionMetadataMap().get(topic); - this.converter = new Tuple2StreamConverter(spoutSpec.getTuple2StreamMetadataMap().get(topic)); - this.sds = sds; - } - - @Override - public StreamDefinition getStreamDefinition(String streamId) { - return this.sds.get(streamId); - } -} \ No newline at end of file
http://git-wip-us.apache.org/repos/asf/eagle/blob/6fd95d5c/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/main/java/org/apache/eagle/alert/engine/utils/AlertStreamUtils.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/main/java/org/apache/eagle/alert/engine/utils/AlertStreamUtils.java b/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/main/java/org/apache/eagle/alert/engine/utils/AlertStreamUtils.java deleted file mode 100644 index fc9cc8a..0000000 --- a/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/main/java/org/apache/eagle/alert/engine/utils/AlertStreamUtils.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * 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 - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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. - */ -package org.apache.eagle.alert.engine.utils; - -import org.apache.eagle.alert.engine.coordinator.PolicyDefinition; -import org.apache.eagle.alert.engine.coordinator.StreamDefinition; -import org.apache.eagle.alert.engine.evaluator.PolicyHandlerContext; -import org.apache.eagle.alert.engine.model.AlertStreamEvent; -import org.apache.eagle.alert.engine.model.StreamEvent; - -import java.util.Map; - -/** - * Created on 8/16/16. - */ -public class AlertStreamUtils { - - /** - * Create alert stream event for publisher. - */ - public static AlertStreamEvent createAlertEvent(StreamEvent event, - PolicyHandlerContext context, - Map<String, StreamDefinition> sds) { - PolicyDefinition policyDef = context.getPolicyDefinition(); - AlertStreamEvent alertStreamEvent = new AlertStreamEvent(); - - alertStreamEvent.setTimestamp(event.getTimestamp()); - alertStreamEvent.setData(event.getData()); - alertStreamEvent.setStreamId(policyDef.getOutputStreams().get(0)); - alertStreamEvent.setPolicyId(policyDef.getName()); - - if (context.getPolicyEvaluator() != null) { - alertStreamEvent.setCreatedBy(context.getPolicyEvaluator().getName()); - } - - alertStreamEvent.setCreatedTime(System.currentTimeMillis()); - - String is = policyDef.getInputStreams().get(0); - StreamDefinition sd = sds.get(is); - alertStreamEvent.setSchema(sd); - - return alertStreamEvent; - } -} http://git-wip-us.apache.org/repos/asf/eagle/blob/6fd95d5c/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/main/java/org/apache/eagle/alert/engine/utils/CompressionUtils.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/main/java/org/apache/eagle/alert/engine/utils/CompressionUtils.java b/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/main/java/org/apache/eagle/alert/engine/utils/CompressionUtils.java deleted file mode 100644 index 075d827..0000000 --- a/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/main/java/org/apache/eagle/alert/engine/utils/CompressionUtils.java +++ /dev/null @@ -1,65 +0,0 @@ -/** - * 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. - */ -package org.apache.eagle.alert.engine.utils; - -import com.google.common.io.ByteStreams; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.OutputStream; -import java.util.zip.GZIPInputStream; -import java.util.zip.GZIPOutputStream; - - -public class CompressionUtils { - public static byte[] compress(byte[] source) throws IOException { - if (source == null || source.length == 0) { - return source; - } - ByteArrayInputStream sourceStream = new ByteArrayInputStream(source); - ByteArrayOutputStream outputStream = new ByteArrayOutputStream(source.length / 2); - try (OutputStream compressor = new GZIPOutputStream(outputStream)) { - ByteStreams.copy(sourceStream, compressor); - compressor.close(); - } - try { - return outputStream.toByteArray(); - } finally { - sourceStream.close(); - outputStream.close(); - } - } - - public static byte[] decompress(byte[] compressed) throws IOException { - if (compressed == null || compressed.length == 0) { - return compressed; - } - ByteArrayInputStream sourceStream = new ByteArrayInputStream(compressed); - ByteArrayOutputStream outputStream = new ByteArrayOutputStream(compressed.length * 2); - try (GZIPInputStream compressor = new GZIPInputStream(sourceStream)) { - ByteStreams.copy(compressor, outputStream); - compressor.close(); - } - try { - return outputStream.toByteArray(); - } finally { - sourceStream.close(); - outputStream.close(); - } - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/eagle/blob/6fd95d5c/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/main/java/org/apache/eagle/alert/engine/utils/MetadataSerDeser.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/main/java/org/apache/eagle/alert/engine/utils/MetadataSerDeser.java b/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/main/java/org/apache/eagle/alert/engine/utils/MetadataSerDeser.java deleted file mode 100644 index 2229219..0000000 --- a/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/main/java/org/apache/eagle/alert/engine/utils/MetadataSerDeser.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * - * * 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 - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * 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. - * - */ - -package org.apache.eagle.alert.engine.utils; - -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.type.TypeReference; -import com.fasterxml.jackson.databind.ObjectMapper; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.InputStream; - -/** - * Since 5/6/16. - */ -public class MetadataSerDeser { - private static final Logger LOG = LoggerFactory.getLogger(MetadataSerDeser.class); - - @SuppressWarnings("rawtypes") - public static <K> K deserialize(InputStream is, TypeReference typeRef) { - ObjectMapper mapper = new ObjectMapper(); - try { - K spec = mapper.readValue(is, typeRef); - return spec; - } catch (Exception ex) { - LOG.error("error in deserializing metadata of type {} from input stream", - new TypeReference<K>() { - }.getType().getClass().getCanonicalName(), ex); - } - return null; - } - - public static <K> K deserialize(InputStream is, Class<K> cls) { - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(JsonParser.Feature.ALLOW_COMMENTS, true); - try { - K spec = mapper.readValue(is, cls); - return spec; - } catch (Exception ex) { - LOG.error("Got error to deserialize metadata of type {} from input stream", - new TypeReference<K>() { - }.getType().getClass().getCanonicalName(), ex); - } - return null; - } - - @SuppressWarnings("rawtypes") - public static <K> K deserialize(String json, TypeReference typeRef) { - ObjectMapper mapper = new ObjectMapper(); - try { - K spec = mapper.readValue(json, typeRef); - return spec; - } catch (Exception ex) { - LOG.error("error in deserializing metadata of type {} from {}", - new TypeReference<K>() { - }.getType().getClass().getCanonicalName(), json, ex); - } - return null; - } - - public static <K> K deserialize(String json, Class<K> cls) { - ObjectMapper mapper = new ObjectMapper(); - try { - K spec = mapper.readValue(json, cls); - return spec; - } catch (Exception ex) { - LOG.error("error in deserializing metadata of type {} from {}", - new TypeReference<K>() { - }.getType().getClass().getCanonicalName(), json, ex); - } - return null; - } - - public static <K> String serialize(K spec) { - ObjectMapper mapper = new ObjectMapper(); - try { - String json = mapper.writeValueAsString(spec); - return json; - } catch (Exception ex) { - LOG.error("error in serializing object {} with type {}", spec, - new TypeReference<K>() { - }.getType().getClass().getCanonicalName(), ex); - } - return null; - } -} http://git-wip-us.apache.org/repos/asf/eagle/blob/6fd95d5c/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/main/java/org/apache/eagle/alert/engine/utils/SerializableUtils.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/main/java/org/apache/eagle/alert/engine/utils/SerializableUtils.java b/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/main/java/org/apache/eagle/alert/engine/utils/SerializableUtils.java deleted file mode 100644 index 509cbf4..0000000 --- a/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/main/java/org/apache/eagle/alert/engine/utils/SerializableUtils.java +++ /dev/null @@ -1,122 +0,0 @@ -/* - * 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 - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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. - */ -package org.apache.eagle.alert.engine.utils; - -import org.xerial.snappy.SnappyInputStream; -import org.xerial.snappy.SnappyOutputStream; - -import java.io.*; - - -/** - * Utilities for working with Serializables. - * Derived from "com.google.cloud.dataflow.sdk.util.SerializableUtils" - */ -public class SerializableUtils { - /** - * Serializes the argument into an array of bytes, and returns it. - * - * @throws IllegalArgumentException if there are errors when serializing - */ - public static byte[] serializeToCompressedByteArray(Object value) { - try { - ByteArrayOutputStream buffer = new ByteArrayOutputStream(); - try (ObjectOutputStream oos = new ObjectOutputStream(new SnappyOutputStream(buffer))) { - oos.writeObject(value); - } - return buffer.toByteArray(); - } catch (IOException exn) { - throw new IllegalArgumentException( - "unable to serialize " + value, - exn); - } - } - - /** - * Serializes the argument into an array of bytes, and returns it. - * - * @throws IllegalArgumentException if there are errors when serializing - */ - public static byte[] serializeToByteArray(Object value) { - try { - ByteArrayOutputStream buffer = new ByteArrayOutputStream(); - try (ObjectOutputStream oos = new ObjectOutputStream(buffer)) { - oos.writeObject(value); - } - return buffer.toByteArray(); - } catch (IOException exn) { - throw new IllegalArgumentException("unable to serialize " + value, exn); - } - } - - /** - * Deserializes an object from the given array of bytes, e.g., as - * serialized using {@link #serializeToCompressedByteArray}, and returns it. - * - * @throws IllegalArgumentException if there are errors when - * deserializing, using the provided description to identify what - * was being deserialized - */ - public static Object deserializeFromByteArray(byte[] encodedValue, - String description) { - try { - try (ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(encodedValue))) { - return ois.readObject(); - } - } catch (IOException | ClassNotFoundException exn) { - throw new IllegalArgumentException( - "unable to deserialize " + description, - exn); - } - } - - /** - * Deserializes an object from the given array of bytes, e.g., as - * serialized using {@link #serializeToCompressedByteArray}, and returns it. - * - * @throws IllegalArgumentException if there are errors when - * deserializing, using the provided description to identify what - * was being deserialized - */ - public static Object deserializeFromCompressedByteArray(byte[] encodedValue, - String description) { - try { - try (ObjectInputStream ois = new ObjectInputStream( - new SnappyInputStream(new ByteArrayInputStream(encodedValue)))) { - return ois.readObject(); - } - } catch (IOException | ClassNotFoundException exn) { - throw new IllegalArgumentException( - "unable to deserialize " + description, - exn); - } - } - - public static <T extends Serializable> T ensureSerializable(T value) { - @SuppressWarnings("unchecked") - T copy = (T) deserializeFromCompressedByteArray(serializeToCompressedByteArray(value), - value.toString()); - return copy; - } - - public static <T extends Serializable> T clone(T value) { - @SuppressWarnings("unchecked") - T copy = (T) deserializeFromCompressedByteArray(serializeToCompressedByteArray(value), - value.toString()); - return copy; - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/eagle/blob/6fd95d5c/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/main/java/org/apache/eagle/alert/engine/utils/SingletonExecutor.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/main/java/org/apache/eagle/alert/engine/utils/SingletonExecutor.java b/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/main/java/org/apache/eagle/alert/engine/utils/SingletonExecutor.java deleted file mode 100644 index fdb9ed8..0000000 --- a/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/main/java/org/apache/eagle/alert/engine/utils/SingletonExecutor.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * - * * 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 - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * 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. - * - */ - -package org.apache.eagle.alert.engine.utils; - -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; - -public class SingletonExecutor { - - public static synchronized ExecutorService getExecutorService() { - return executorService; - } - - private static ExecutorService executorService; - - private static SingletonExecutor executor = new SingletonExecutor(); - - public SingletonExecutor() { - executorService = Executors.newFixedThreadPool(5); - } - - public static void main(String[] args) { - System.out.println(SingletonExecutor.getExecutorService()); - System.out.println(SingletonExecutor.getExecutorService()); - - } -} http://git-wip-us.apache.org/repos/asf/eagle/blob/6fd95d5c/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/main/java/storm/kafka/KafkaSpoutMetric.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/main/java/storm/kafka/KafkaSpoutMetric.java b/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/main/java/storm/kafka/KafkaSpoutMetric.java deleted file mode 100644 index 935742f..0000000 --- a/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/main/java/storm/kafka/KafkaSpoutMetric.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * 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 - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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. - */ -package storm.kafka; - -import backtype.storm.metric.api.IMetric; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.*; -import java.util.concurrent.ConcurrentHashMap; - -/** - * Since 5/18/16. - * The original storm.kafka.KafkaSpout has some issues like the following - * 1) can only support one single topic - * 2) can only be initialized at open(), can't dynamically support another topic. - */ -public class KafkaSpoutMetric implements IMetric { - @SuppressWarnings("unused") - private static final Logger LOG = LoggerFactory.getLogger(KafkaSpoutMetric.class); - private Map<String, KafkaSpoutMetricContext> metricContextMap = new ConcurrentHashMap<>(); - private Map<String, KafkaUtils.KafkaOffsetMetric> offsetMetricMap = new ConcurrentHashMap<>(); - - public static class KafkaSpoutMetricContext { - SpoutConfig spoutConfig; - DynamicPartitionConnections connections; - PartitionCoordinator coordinator; - } - - public void addTopic(String topic, KafkaSpoutMetricContext context) { - // construct KafkaOffsetMetric - KafkaUtils.KafkaOffsetMetric kafkaOffsetMetric = new KafkaUtils.KafkaOffsetMetric(context.spoutConfig.topic, context.connections); - metricContextMap.put(topic, context); - offsetMetricMap.put(topic, kafkaOffsetMetric); - } - - public void removeTopic(String topic) { - metricContextMap.remove(topic); - offsetMetricMap.remove(topic); - } - - @SuppressWarnings( {"unchecked", "rawtypes"}) - @Override - public Object getValueAndReset() { - HashMap spoutMetric = new HashMap(); - for (Map.Entry<String, KafkaSpoutMetricContext> entry : metricContextMap.entrySet()) { - // construct offset metric - List<PartitionManager> pms = entry.getValue().coordinator.getMyManagedPartitions(); - Set<Partition> latestPartitions = new HashSet(); - for (PartitionManager pm : pms) { - latestPartitions.add(pm.getPartition()); - } - - KafkaUtils.KafkaOffsetMetric offsetMetric = offsetMetricMap.get(entry.getKey()); - offsetMetric.refreshPartitions(latestPartitions); - for (PartitionManager pm : pms) { - offsetMetric.setLatestEmittedOffset(pm.getPartition(), pm.lastCompletedOffset()); - } - Object o = offsetMetric.getValueAndReset(); - if (o != null) { - ((HashMap) o).forEach( - (k, v) -> spoutMetric.put(k + "_" + entry.getKey(), v) - ); - } - - // construct partition metric - for (PartitionManager pm : pms) { - pm.getMetricsDataMap().forEach( - (k, v) -> spoutMetric.put(k + "_" + entry.getKey(), v) - ); - } - } - return spoutMetric; - } -} http://git-wip-us.apache.org/repos/asf/eagle/blob/6fd95d5c/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/main/java/storm/kafka/KafkaSpoutWrapper.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/main/java/storm/kafka/KafkaSpoutWrapper.java b/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/main/java/storm/kafka/KafkaSpoutWrapper.java deleted file mode 100644 index 2bdbd3c..0000000 --- a/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/main/java/storm/kafka/KafkaSpoutWrapper.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * - * * 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 - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * 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. - * - */ -package storm.kafka; - -import org.apache.eagle.alert.coordination.model.SpoutSpec; -import org.apache.eagle.alert.engine.coordinator.StreamDefinition; -import org.apache.eagle.alert.engine.spout.ISpoutSpecLCM; -import org.apache.eagle.alert.engine.spout.SpoutOutputCollectorWrapper; -import backtype.storm.Config; -import backtype.storm.spout.SpoutOutputCollector; -import backtype.storm.task.TopologyContext; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * NOTE!!!!! This class copy/paste some code from storm.kafka.KafkaSpout to make sure it can support one process to hold multiple - * KafkaSpout - * - * <p>this collectorWrapper provides the following capabilities: - * 1. inject customized collector collectorWrapper, so framework can control traffic routing - * 2. listen to topic to stream metadata change and pass that to customized collector collectorWrapper - * 3. return current streams for this topic</p> - */ -public class KafkaSpoutWrapper extends KafkaSpout implements ISpoutSpecLCM { - private static final long serialVersionUID = 5507693757424351306L; - @SuppressWarnings("unused") - private static final Logger LOG = LoggerFactory.getLogger(KafkaSpoutWrapper.class); - private KafkaSpoutMetric kafkaSpoutMetric; - - public KafkaSpoutWrapper(SpoutConfig spoutConf, KafkaSpoutMetric kafkaSpoutMetric) { - super(spoutConf); - this.kafkaSpoutMetric = kafkaSpoutMetric; - } - - private SpoutOutputCollectorWrapper collectorWrapper; - - @SuppressWarnings( {"unchecked", "rawtypes"}) - @Override - public void open(Map conf, final TopologyContext context, final SpoutOutputCollector collector) { - String topologyInstanceId = context.getStormId(); - ////// !!!! begin copying code from storm.kafka.KafkaSpout to here - _collector = collector; - - Map stateConf = new HashMap(conf); - List<String> zkServers = _spoutConfig.zkServers; - if (zkServers == null) { - zkServers = (List<String>) conf.get(Config.STORM_ZOOKEEPER_SERVERS); - } - Integer zkPort = _spoutConfig.zkPort; - if (zkPort == null) { - zkPort = ((Number) conf.get(Config.STORM_ZOOKEEPER_PORT)).intValue(); - } - stateConf.put(Config.TRANSACTIONAL_ZOOKEEPER_SERVERS, zkServers); - stateConf.put(Config.TRANSACTIONAL_ZOOKEEPER_PORT, zkPort); - stateConf.put(Config.TRANSACTIONAL_ZOOKEEPER_ROOT, _spoutConfig.zkRoot); - _state = new ZkState(stateConf); - - _connections = new DynamicPartitionConnections(_spoutConfig, KafkaUtils.makeBrokerReader(conf, _spoutConfig)); - - // using TransactionalState like this is a hack - int totalTasks = context.getComponentTasks(context.getThisComponentId()).size(); - if (_spoutConfig.hosts instanceof StaticHosts) { - _coordinator = new StaticCoordinator(_connections, conf, _spoutConfig, _state, context.getThisTaskIndex(), totalTasks, topologyInstanceId); - } else { - _coordinator = new ZkCoordinator(_connections, conf, _spoutConfig, _state, context.getThisTaskIndex(), totalTasks, topologyInstanceId); - } - - ////// !!!! end copying code from storm.kafka.KafkaSpout to here - - // add new topic to metric - KafkaSpoutMetric.KafkaSpoutMetricContext metricContext = new KafkaSpoutMetric.KafkaSpoutMetricContext(); - metricContext.connections = _connections; - metricContext.coordinator = _coordinator; - metricContext.spoutConfig = _spoutConfig; - kafkaSpoutMetric.addTopic(_spoutConfig.topic, metricContext); - - this.collectorWrapper = (SpoutOutputCollectorWrapper) collector; - } - - @Override - public void update(SpoutSpec metadata, Map<String, StreamDefinition> sds) { - collectorWrapper.update(metadata, sds); - } - - @Override - public void close() { - super.close(); - kafkaSpoutMetric.removeTopic(_spoutConfig.topic); - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/eagle/blob/6fd95d5c/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/main/resources/ALERT_DEFAULT_TEMPLATE.vm ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/main/resources/ALERT_DEFAULT_TEMPLATE.vm b/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/main/resources/ALERT_DEFAULT_TEMPLATE.vm deleted file mode 100644 index 3926cc8..0000000 --- a/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/main/resources/ALERT_DEFAULT_TEMPLATE.vm +++ /dev/null @@ -1,301 +0,0 @@ -<!-- - ~ 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 - ~ - ~ http://www.apache.org/licenses/LICENSE-2.0 - ~ - ~ 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. - --> -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml"> - #set ( $alert = $alertList[0] ) -<head> - <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> - <meta name="viewport" content="width=device-width"/> - <title>$alert["alertSubject"]</title> - <style> - body { - width: 100% !important; - min-width: 100%; - -webkit-text-size-adjust: 100%; - -ms-text-size-adjust: 100%; - margin: 0; - padding: 0; - } - - table { - border-spacing: 0; - border-collapse: collapse; - } - - table th, - table td { - padding: 3px 0 3px 0; - } - - .body { - width: 100%; - } - - p, a, h1, h2, h3, ul, ol, li { - font-family: Helvetica, Arial, sans-serif; - font-weight: normal; - margin: 0; - padding: 0; - } - - p { - font-size: 14px; - line-height: 19px; - } - - a { - color: #3294b1; - } - - h1 { - font-size: 36px; - margin: 15px 0 5px 0; - } - - h2 { - font-size: 32px; - } - - h3 { - font-size: 28px; - } - - ul, ol { - margin: 0 0 0 25px; - padding: 0; - } - - .btn { - background: #2ba6cb !important; - border: 1px solid #2284a1; - padding: 10px 20px 10px 20px; - text-align: center; - } - - .btn:hover { - background: #2795b6 !important; - } - - .btn a { - color: #FFFFFF; - text-decoration: none; - font-weight: bold; - padding: 10px 20px 10px 20px; - } - - .tableBordered { - border-top: 1px solid #b9e5ff; - } - - .tableBordered th { - background: #ECF8FF; - } - - .tableBordered th p { - font-weight: bold; - color: #3294b1; - } - - .tableBordered th, - .tableBordered td { - color: #333333; - border-bottom: 1px solid #b9e5ff; - text-align: center; - padding-bottom: 5px; - } - - .panel { - height: 100px; - } - </style> -</head> -<body> -<table class="body"> - <tr> - <td align="center" valign="top" style="background: #999999; padding: 0 0 0 0;"> - <!-- Header --> - <table width="580"> - <tr> - <td style="padding: 0 0 0 0;" align="left"> - <p style="color:#FFFFFF;font-weight: bold; font-size: 22px">Eagle Alert Notification</p> - </td> - </tr> - </table> - </td> - </tr> - <tr> - <td align="center" valign="top"> - <!-- Eagle Body --> - <table width="580"> - <tr> - <!-- Title --> - <td align="center"> - <h2>Warning: $alert["alertSubject"]</h2> - </td> - </tr> - <tr> - <!-- Time --> - <td> - <table width="580"> - <tr> - <td> - <p><b>Detected Time: $alert["alertTime"]</b></p> - </td> - #set ( $alertSeverity = $alert["alertSeverity"] ) - #if (!$alertSeverity || ("$alertSeverity" == "")) - #set ( $alert["alertSeverity"] = "WARNING") - #end - <td align="right"> - <p><b> - Severity: - #if ($alert["alertSeverity"] == "WARNING") - <span>$alert["alertSeverity"]</span> - #else - <span style="color: #FF0000;">$alert["alertSeverity"]</span> - #end - </b></p> - </td> - </tr> - </table> - </td> - </tr> - - <tr> - <!-- Basic Information --> - <td style="padding: 20px 0 10px 0;"> - <p><b>Alert Message </b></p> - </td> - </tr> - <tr> - <!-- Description --> - <td valign="top" - style="background: #ECF8FF; border: 1px solid #b9e5ff; padding: 10px 10px 12px 20px;"> - <p>$alert["alertBody"]</p> - </td> - </tr> - <tr> - <!-- Basic Information --> - <td style="padding: 20px 0 10px 0;"> - <p><b>Alert Detail</b></p> - </td> - </tr> - <tr> - <!-- Basic Information Content --> - <td> - <table class="tableBordered" width="580"> - <tr> - <th> - <p>Policy Name</p> - </th> - <td> - <p><a href="$alert["policyDetailUrl"]">$alert["policyId"]</a></p> - </td> - </tr> - <tr> - <th> - <p>Severity Level</p> - </th> - <td> - <p>$alert["alertSeverity"]</p> - </td> - </tr> - <tr> - <th> - <p>Alert Stream</p> - </th> - <td> - <p>$alert["streamId"]</p> - </td> - </tr> - <tr> - <th> - <p>Created Time</p> - </th> - <td> - <p>$alert["alertTime"]</p> - </td> - </tr> - <tr> - <th> - <p>Created By</p> - </th> - <td> - <p>$alert["creator"]</p> - </td> - </tr> - </table> - </td> - </tr> -## <tr> -## <!-- View Detail --> -## <td align="center" style="padding: 10px 0 0 0;"> -## <table width="580"> -## <tr> -## <td class="btn"> -## <a href="$alert["policyDetailUrl"]">View Policy Details</a> -## </td> -## </tr> -## </table> -## </td> -## </tr> - - <tr> - <!-- View Detail --> - <td align="center" style="padding: 10px 0 0 0;"> - <table width="580"> - <tr> - <td class="btn"> - <a href="$alert["alertDetailUrl"]">View Alert on Eagle</a> - </td> - </tr> - </table> - </td> - </tr> - <tr> - <!-- Actions Required --> - <td style="padding: 20px 0 10px 0;"> - <p><b>Actions Required</b></p> - </td> - </tr> - <tr> - <!-- Possible Root Causes Content --> - <td class="panel" valign="top" - style="background: #F4F4F4; border: 1px solid #AAAAAA; padding: 10px 10px 12px 10px;"> - <p> - The alert notification was automatically detected and sent by Eagle according to policy: $alert["policyId"]. - To follow-up on this, please verify the alert and diagnose the root cause with Eagle: - </p> - <p></p> - <ul> - <li><p><a href="$alert["alertDetailUrl"]">View alert detail</a></p></li> - <li><p><a href="$alert["policyDetailUrl"]">View policy detail</a></p></li> - <li><p><a href="$alert["homeUrl"]">View eagle home</a></p></li> - </ul> - </td> - </tr> - <tr> - <!-- Copyright --> - <td align="center"> - <p><i>Powered by <a href="http://eagle.incubator.apache.org">Apache Eagle</a> (version: $alert["version"])</i></p> - </td> - </tr> - </table> - </td> - </tr> -</table> -</body> -</html> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/eagle/blob/6fd95d5c/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/main/resources/ALERT_INLINED_TEMPLATE.vm ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/main/resources/ALERT_INLINED_TEMPLATE.vm b/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/main/resources/ALERT_INLINED_TEMPLATE.vm deleted file mode 100644 index 0e3d5fe..0000000 --- a/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/main/resources/ALERT_INLINED_TEMPLATE.vm +++ /dev/null @@ -1,259 +0,0 @@ -<!-- - ~ 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 - ~ - ~ http://www.apache.org/licenses/LICENSE-2.0 - ~ - ~ 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. - --> -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" - "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> - -#set ( $alert = $alertList[0] ) - -## Generate Alert Color -#set($alertColor = "#337ab7") -#if($alert["alertSeverity"] == "WARNING") - #set($alertColor = "#FF9F00") -#elseif($alert["alertSeverity"] == "CRITICAL" || $alert["alertSeverity"] == "FETAL") - #set($alertColor = "#d43f3a") -#elseif ($alert["alertSeverity"] == "OK") - #set($alertColor = "#68B90F") -#end - -<html xmlns="http://www.w3.org/1999/xhtml" - style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;"> -<head> - <meta name="viewport" content="width=device-width"/> - <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> - <title>[$alert["alertSeverity"] $alert["alertSubject"]</title> - <style type="text/css"> - img { - max-width: 100%; - } - - body { - -webkit-font-smoothing: antialiased; - -webkit-text-size-adjust: none; - width: 100% !important; - height: 100%; - line-height: 1.6em; - } - - body { - background-color: #f6f6f6; - } - - @media only screen and (max-width: 640px) { - body { - padding: 0 !important; - } - - h1 { - font-weight: 800 !important; - margin: 20px 0 5px !important; - } - - h2 { - font-weight: 800 !important; - margin: 20px 0 5px !important; - } - - h3 { - font-weight: 800 !important; - margin: 20px 0 5px !important; - } - - h4 { - font-weight: 800 !important; - margin: 20px 0 5px !important; - } - - h1 { - font-size: 22px !important; - } - - h2 { - font-size: 18px !important; - } - - h3 { - font-size: 16px !important; - } - - .container { - padding: 0 !important; - width: 100% !important; - } - - .content { - padding: 0 !important; - } - - .content-wrap { - padding: 10px !important; - } - - .invoice { - width: 100% !important; - } - } - </style> -</head> - -<body itemscope itemtype="http://schema.org/EmailMessage" - style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: none; width: 100% !important; height: 100%; line-height: 1.6em; background-color: #f6f6f6; margin: 0;" - bgcolor="#f6f6f6"> - -<table class="body-wrap" - style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; width: 100%; background-color: #f6f6f6; margin: 0;" - bgcolor="#f6f6f6"> - <tr style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;"> - <td style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; vertical-align: top; margin: 0;" - valign="top"></td> - <td class="container" width="600" - style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; vertical-align: top; display: block !important; max-width: 600px !important; clear: both !important; margin: 0 auto;" - valign="top"> - <div class="content" - style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; max-width: 600px; display: block; margin: 0 auto; padding: 20px;"> - <table class="main" width="100%" cellpadding="0" cellspacing="0" - style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; border-radius: 3px; background-color: #fff; margin: 0; border: 1px solid #e9e9e9;" - bgcolor="#fff"> - <tr style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;"> - <td class="alert alert-warning" - style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 16px; vertical-align: top; color: #fff; font-weight: 500; text-align: center; border-radius: 3px 3px 0 0; background-color: $alertColor; margin: 0; padding: 20px;" - align="center" bgcolor="$alertColor" valign="top"> - <strong >$alert["alertSeverity"]: </strong> - $alert["alertSubject"] - </td> - </tr> - <tr style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;"> - <td class="content-wrap" - style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; vertical-align: top; margin: 0; padding: 20px;" - valign="top"> - <table width="100%" cellpadding="0" cellspacing="0" - style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;"> - <tr style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;"> - <td class="content-block" - style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; vertical-align: top; margin: 0; padding: 0 0 20px;" - valign="top"> - <small>CATEGORY:</small> <strong style="color: $alertColor">#if($alert["alertCategory"]) $alert["alertCategory"] #else N/A #end</strong> <small>TIME:</small> <strong>$alert["alertTime"]</strong> - </td> - </tr> - <tr style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;"> - <td class="content-block" - style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; vertical-align: top; margin: 0 4px; padding: 10px 10px; background-color: #eee;" - valign="top"> - <div style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; vertical-align: top;"> - $alert["alertBody"] - </div> - </td> - </tr> - - <tr style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;"> - <td class="content-block aligncenter" - style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; vertical-align: top; text-align: center; margin: 0; padding: 0 0 10px;" - align="center" valign="top"> - <table class="invoice" - style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; text-align: left; width: 90%; margin: 10px auto;"> - <tr style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;"> - <td style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; vertical-align: top; margin: 0; padding: 5px 0;" - valign="top"> - <table class="invoice-items" cellpadding="0" cellspacing="0" - style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; width: 100%; margin: 0;"> - <tr style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;"> - <td style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; vertical-align: top; margin: 0; padding: 5px 0;" - valign="top"> - Severity - </td> - <td style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; vertical-align: top; margin: 0; padding: 5px 0;" - valign="top"> $alert["alertSeverity"] - </td> - </tr> - <tr style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;"> - <td style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; vertical-align: top; border-top-width: 1px; border-top-color: #eee; border-top-style: solid; margin: 0; padding: 5px 0;" - valign="top">Category - </td> - <td class="alignright" - style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; vertical-align: top; text-align: left; border-top-width: 1px; border-top-color: #eee; border-top-style: solid; margin: 0; padding: 5px 0;" - align="right" valign="top"> - #if($alert["alertCategory"]) - $alert["alertCategory"] - #else - N/A - #end - </td> - </tr> - <tr style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;"> - <td style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; vertical-align: top; border-top-width: 1px; border-top-color: #eee; border-top-style: solid; margin: 0; padding: 5px 0;" - valign="top">Cluster - </td> - <td class="alignright" - style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; vertical-align: top; text-align: left; border-top-width: 1px; border-top-color: #eee; border-top-style: solid; margin: 0; padding: 5px 0;" - align="right" valign="top">$alert["siteId"] - </td> - </tr> - <tr style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;"> - <td style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; vertical-align: top; border-top-width: 1px; border-top-color: #eee; border-top-style: solid; margin: 0; padding: 5px 0;" - valign="top">Policy - </td> - <td class="alignright" - style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; vertical-align: top; text-align: left; border-top-width: 1px; border-top-color: #eee; border-top-style: solid; margin: 0; padding: 5px 0;" - align="right" valign="top"><a - href="$alert["policyDetailUrl"]" - style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; color: #999; text-decoration: underline; margin: 0;">$alert[ - "policyId"]</a> - </td> - </tr> - </table> - </td> - </tr> - </table> - </td> - </tr> - - <tr style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;"> - <td class="content-block" - style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; vertical-align: top; margin: 0; padding: 0 0 20px;" - valign="top"> - <a href="$alert["alertDetailUrl"]" class="btn-primary" - style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; color: #FFF; text-decoration: none; line-height: 2em; font-weight: bold; text-align: center; cursor: pointer; display: inline-block; border-radius: 5px; text-transform: capitalize; background-color: $alertColor; margin: 0; border-color: $alertColor; border-style: solid; border-width: 10px 20px;"> - View Alert Details - </a> - </td> - </tr> - </table> - </td> - </tr> - </table> - <div class="footer" - style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; width: 100%; clear: both; color: #999; margin: 0; padding: 20px;"> - <table width="100%" - style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;"> - <tr style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;"> - <td class="aligncenter content-block" - style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 12px; vertical-align: top; color: #999; text-align: center; margin: 0; padding: 0 0 20px;" - align="center" valign="top"> - Powered by <a href="http://eagle.incubator.apache.org" - style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 12px; color: #999; text-decoration: underline; margin: 0;">Apache - Eagle</a> (version: $alert["version"]) - </td> - </tr> - </table> - </div> - </div> - </td> - <td style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; vertical-align: top; margin: 0;" - valign="top"></td> - </tr> -</table> -</body> -</html> http://git-wip-us.apache.org/repos/asf/eagle/blob/6fd95d5c/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/main/resources/ALERT_LIGHT_TEMPLATE.vm ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/main/resources/ALERT_LIGHT_TEMPLATE.vm b/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/main/resources/ALERT_LIGHT_TEMPLATE.vm deleted file mode 100644 index f273917..0000000 --- a/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/main/resources/ALERT_LIGHT_TEMPLATE.vm +++ /dev/null @@ -1,495 +0,0 @@ -<!-- - ~ 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 - ~ - ~ http://www.apache.org/licenses/LICENSE-2.0 - ~ - ~ 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. - --> -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml"> - - #set ( $alert = $alertList[0] ) -<head> - <meta name="viewport" content="width=device-width" /> - <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> - <title>[$alert["alertSeverity"]$alert["alertSubject"]</title> - <style rel="stylesheet" type="text/css"> - /* ------------------------------------- - GLOBAL - A very basic CSS reset - ------------------------------------- */ - * { - margin: 0; - font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; - box-sizing: border-box; - font-size: 14px; - } - - img { - max-width: 100%; - } - - body { - -webkit-font-smoothing: antialiased; - -webkit-text-size-adjust: none; - width: 100% !important; - height: 100%; - line-height: 1.6em; - /* 1.6em * 14px = 22.4px, use px to get airier line-height also in Thunderbird, and Yahoo!, Outlook.com, AOL webmail clients */ - /*line-height: 22px;*/ - } - - /* Let's make sure all tables have defaults */ - table td { - vertical-align: top; - } - - /* ------------------------------------- - BODY & CONTAINER - ------------------------------------- */ - body { - background-color: #f6f6f6; - } - - .body-wrap { - background-color: #f6f6f6; - width: 100%; - } - - .container { - display: block !important; - max-width: 600px !important; - margin: 0 auto !important; - /* makes it centered */ - clear: both !important; - } - - .content { - max-width: 600px; - margin: 0 auto; - display: block; - padding: 20px; - } - - /* ------------------------------------- - HEADER, FOOTER, MAIN - ------------------------------------- */ - .main { - background-color: #fff; - border: 1px solid #e9e9e9; - border-radius: 3px; - } - - .content-wrap { - padding: 20px; - } - - .content-block { - padding: 0 0 20px; - } - - .header { - width: 100%; - margin-bottom: 20px; - } - - .footer { - width: 100%; - clear: both; - color: #999; - padding: 20px; - } - .footer p, .footer a, .footer td { - color: #999; - font-size: 12px; - } - - /* ------------------------------------- - TYPOGRAPHY - ------------------------------------- */ - h1, h2, h3 { - font-family: "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif; - color: #000; - margin: 40px 0 0; - line-height: 1.2em; - font-weight: 400; - } - - h1 { - font-size: 32px; - font-weight: 500; - /* 1.2em * 32px = 38.4px, use px to get airier line-height also in Thunderbird, and Yahoo!, Outlook.com, AOL webmail clients */ - /*line-height: 38px;*/ - } - - h2 { - font-size: 24px; - /* 1.2em * 24px = 28.8px, use px to get airier line-height also in Thunderbird, and Yahoo!, Outlook.com, AOL webmail clients */ - /*line-height: 29px;*/ - } - - h3 { - font-size: 18px; - /* 1.2em * 18px = 21.6px, use px to get airier line-height also in Thunderbird, and Yahoo!, Outlook.com, AOL webmail clients */ - /*line-height: 22px;*/ - } - - h4 { - font-size: 14px; - font-weight: 600; - } - - p, ul, ol { - margin-bottom: 10px; - font-weight: normal; - } - p li, ul li, ol li { - margin-left: 5px; - list-style-position: inside; - } - - - /* ------------------------------------- - LINKS & BUTTONS - ------------------------------------- */ - a { - color: #348eda; - text-decoration: underline; - } - - .btn-primary { - text-decoration: none; - color: #FFF; - background-color: #348eda; - border: solid #348eda; - border-width: 10px 20px; - line-height: 2em; - /* 2em * 14px = 28px, use px to get airier line-height also in Thunderbird, and Yahoo!, Outlook.com, AOL webmail clients */ - /*line-height: 28px;*/ - font-weight: bold; - text-align: center; - cursor: pointer; - display: inline-block; - border-radius: 5px; - text-transform: capitalize; - } - - .btn-warning { - text-decoration: none; - color: #FFF; - background-color: #f0ad4e; - border-color: solid #eea236; - /*background-color: #348eda;*/ - /*border: solid #348eda;*/ - border-width: 10px 20px; - line-height: 2em; - /* 2em * 14px = 28px, use px to get airier line-height also in Thunderbird, and Yahoo!, Outlook.com, AOL webmail clients */ - /*line-height: 28px;*/ - font-weight: bold; - text-align: center; - cursor: pointer; - display: inline-block; - border-radius: 5px; - text-transform: capitalize; - } - - .btn-danger { - text-decoration: none; - color: #fff; - background-color: #d9534f; - border-color: solid #d43f3a; - /*color: #FFF;*/ - /*background-color: #348eda;*/ - /*border: solid #348eda;*/ - border-width: 10px 20px; - line-height: 2em; - /* 2em * 14px = 28px, use px to get airier line-height also in Thunderbird, and Yahoo!, Outlook.com, AOL webmail clients */ - /*line-height: 28px;*/ - font-weight: bold; - text-align: center; - cursor: pointer; - display: inline-block; - border-radius: 5px; - text-transform: capitalize; - } - - .text-light { - color: #eee; - } - - .text-primary { - color: #348eda; - } - - .text-warning { - color: #eea236 - } - - .text-danger { - color: #d43f3a; - } - - .label { - display: inline; - padding: .2em .6em .3em; - font-size: 75%; - font-weight: 700; - line-height: 1; - color: #fff; - text-align: center; - white-space: nowrap; - vertical-align: baseline; - border-radius: .25em; - } - - .label-ok { - background-color: #777; - } - .label-default { - background-color: #777; - } - .label-primary { - background-color: #337ab7; - } - .label-critical { - background-color: #d9534f; - } - .label-warning { - background-color: #f0ad4e; - } - - /* ------------------------------------- - OTHER STYLES THAT MIGHT BE USEFUL - ------------------------------------- */ - .last { - margin-bottom: 0; - } - - .first { - margin-top: 0; - } - - .aligncenter { - text-align: center; - } - - .alignright { - text-align: right; - } - - .alignleft { - text-align: left; - } - - .clear { - clear: both; - } - - /* ------------------------------------- - ALERTS - Change the class depending on warning email, good email or bad email - ------------------------------------- */ - .alert { - font-size: 16px; - color: #fff; - font-weight: 500; - padding: 20px; - text-align: center; - border-radius: 3px 3px 0 0; - } - .alert a { - color: #fff; - text-decoration: none; - font-weight: 500; - font-size: 16px; - } - .alert.alert-warning { - background-color: #FF9F00; - } - .alert.alert-bad { - background-color: #D0021B; - } - .alert.alert-critical { - background-color: #D0021B; - } - .alert.alert-fetal { - background-color: #D0021B; - } - .alert.alert-ok { - background-color: #68B90F; - } - - .alert-body { - margin-bottom: 10px; - padding: 8px; - background-color: #fff; - border: 1px solid transparent; - border-radius: 4px; - -webkit-box-shadow: 0 1px 1px rgba(0,0,0,.05); - box-shadow: 0 1px 1px rgba(0,0,0,.05); - } - .alert-body-default { - border-color: #eee; - } - .alert-body-primary { - border-color: #337ab7; - } - .alert-body-warning { - border-color: #faebcc; - } - .alert-body-danger { - border-color: #ebccd1; - } - /* ------------------------------------- - INVOICE - Styles for the billing table - ------------------------------------- */ - .invoice { - margin: 40px auto; - text-align: left; - width: 80%; - } - .invoice td { - padding: 5px 0; - } - .invoice .invoice-items { - width: 100%; - } - .invoice .invoice-items td { - border-bottom: #eee 1px solid; - } - .invoice .invoice-items .total td { - border-top: 2px solid #333; - border-bottom: 2px solid #333; - font-weight: 700; - } - - /* ------------------------------------- - RESPONSIVE AND MOBILE FRIENDLY STYLES - ------------------------------------- */ - @media only screen and (max-width: 640px) { - body { - padding: 0 !important; - } - h1, h2, h3, h4 { - font-weight: 800 !important; - margin: 20px 0 5px !important; - } - h1 { - font-size: 22px !important; - } - - h2 { - font-size: 18px !important; - } - h3 { - font-size: 16px !important; - } - .container { - padding: 0 !important; - width: 100% !important; - } - .content { - padding: 0 !important; - } - .content-wrap { - padding: 10px !important; - } - .invoice { - width: 100% !important; - } - } - /*# sourceMappingURL=styles.css.map */ - </style> -</head> - -<body itemscope itemtype="http://schema.org/EmailMessage"> - -<table class="body-wrap"> - <tr> - <td></td> - <td class="container" width="600"> - <div class="content"> - <table class="main" width="100%" cellpadding="0" cellspacing="0"> - <tr> - <td class="alert alert-$alert["alertSeverity"].toLowerCase()"> - <strong>$alert["alertSeverity"]</strong> $alert["alertSubject"] - </td> - </tr> - <tr> - <td class="content-wrap"> - <table width="100%" cellpadding="0" cellspacing="0"> - <tr> - <td class="content-block"> - <table> - <tbody> - <tr> - <td>Category:</td> - <td><strong>$alert["alertCategory"]</strong></td> - <td>Time:</td> - <td><strong>$alert["alertTime"]</strong></td> - </tr> - </tbody> - </table> - </td> - </tr> - <tr> - <td class="content-block"> - <div class="alert-body alert-body-default"> - $alert["alertBody"] - </div> - </td> - </tr> - <tr> - <td class="content-block invoice"> - <table class="invoice-items" cellpadding="0" cellspacing="0"> - <tbody> - <tr> - <td>Cluster</td> - <td>$alert["siteId"]</td> - </tr> - <tr> - <td>Policy</td> - <td><a href="$alert["policyDetailUrl"]">$alert["policyId"]</a></td> - </tr> - </tbody> - </table> - </td> - </tr> - <tr> - <td class="content-block"> - <a href="$alert["alertDetailUrl"]" class="btn-primary">View Alert Details</a> - </td> - </tr> - <tr> - <td class="content-block"> - <i>Note: The alert was automatically detected by <a href="#">Eagle</a>.</i> - </td> - </tr> - </table> - </td> - </tr> - </table> - <div class="footer"> - <table width="100%"> - <tr> - <td class="aligncenter content-block">Powered by <a href="http://eagle.apache.org">Apache Eagle</a> (version: $alert["version"])</td> - </tr> - </table> - </div> - </div> - </td> - <td></td> - </tr> -</table> -</body> -</html>
