Package com.netflix.simianarmy.MonkeyRecorder

Examples of com.netflix.simianarmy.MonkeyRecorder.Event


            throws IOException {
        LOGGER.info("Running on-demand termination for instance group type '{}' and name '{}'",
                groupType, groupName);
        Response.Status responseStatus;
        try {
            Event evt = monkey.terminateNow(groupType, groupName, chaosType);
            if (evt != null) {
                responseStatus = Response.Status.OK;
                gen.writeStringField("monkeyType", evt.monkeyType().name());
                gen.writeStringField("eventId", evt.id());
                gen.writeNumberField("eventTime", evt.eventTime().getTime());
                gen.writeStringField("region", evt.region());
                for (Map.Entry<String, String> pair : evt.fields().entrySet()) {
                    gen.writeStringField(pair.getKey(), pair.getValue());
                }
            } else {
                responseStatus = Response.Status.INTERNAL_SERVER_ERROR;
                gen.writeStringField("message",
View Full Code Here


    private Response.Status optInResource(String resourceId, boolean optIn, JsonGenerator gen)
            throws IOException {
        String op = optIn ? "in" : "out";
        LOGGER.info(String.format("Opt %s resource %s for Janitor Monkey.", op, resourceId));
        Response.Status responseStatus;
        Event evt;
        if (optIn) {
            evt = monkey.optInResource(resourceId);
        } else {
            evt = monkey.optOutResource(resourceId);
        }
        if (evt != null) {
            responseStatus = Response.Status.OK;
            gen.writeStringField("monkeyType", evt.monkeyType().name());
            gen.writeStringField("eventId", evt.id());
            gen.writeNumberField("eventTime", evt.eventTime().getTime());
            gen.writeStringField("region", evt.region());
            for (Map.Entry<String, String> pair : evt.fields().entrySet()) {
                gen.writeStringField(pair.getKey(), pair.getValue());
            }
        } else {
            responseStatus = Response.Status.INTERNAL_SERVER_ERROR;
            gen.writeStringField("message",
View Full Code Here

            return null;
        }
        EventTypes eventType = optIn ? EventTypes.OPT_IN_RESOURCE : EventTypes.OPT_OUT_RESOURCE;
        long timestamp = calendar.now().getTimeInMillis();
        // The same resource can have multiple events, so we add the timestamp to the id.
        Event evt = recorder.newEvent(Type.JANITOR, eventType, region, resourceId + "@" + timestamp);
        recorder.recordEvent(evt);
        resource.setOptOutOfJanitor(!optIn);
        resourceTracker.addOrUpdate(resource);
        return evt;
    }
View Full Code Here

    }

    /** {@inheritDoc} */
    @Override
    public Event recordTermination(InstanceGroup group, String instance, ChaosType chaosType) {
        Event evt = context().recorder().newEvent(Type.CHAOS, EventTypes.CHAOS_TERMINATION, group.region(), instance);
        evt.addField("groupType", group.type().name());
        evt.addField("groupName", group.name());
        evt.addField("chaosType", chaosType.getKey());
        context().recorder().recordEvent(evt);
        return evt;
    }
View Full Code Here

        List<Event> evts = context().recorder().findEvents(Type.CHAOS, EventTypes.CHAOS_TERMINATION, query, after);
        return evts.size();
    }

    private Event createEvent(EventTypes chaosTermination, InstanceGroup group, String instance) {
        Event evt = context().recorder().newEvent(Type.CHAOS, chaosTermination, group.region(), instance);
        evt.addField("groupType", group.type().name());
        evt.addField("groupName", group.name());
        return evt;
    }
View Full Code Here

                    new Object[]{inst, group.name(), group.type(), prop});
            reportEventForSummary(EventTypes.CHAOS_TERMINATION_SKIPPED, group, inst);
            return null;
        } else {
            try {
                Event evt = recordTermination(group, inst, chaosType);
                sendTerminationNotification(group, inst, chaosType);
                SshConfig sshConfig = new SshConfig(cfg);
                ChaosInstance chaosInstance = new ChaosInstance(context().cloudClient(), inst, sshConfig);
                chaosType.apply(chaosInstance);
                LOGGER.info("Terminated {} from group {} [{}] with {}",
View Full Code Here

            if (owner == null && existingOwner != null) {
                // Save the current owner in the tag when we are not able to find a owner.
                owner = existingOwner;
            }
            if (needsUpdate(janitorMetadata, owner, instanceId, lastDetachTime)) {
                Event evt = updateJanitorMetaTag(volume, instanceId, owner, lastDetachTime, awsClient);
                if (evt != null) {
                    context().recorder().recordEvent(evt);
                }
            }
        }
View Full Code Here

        Map<String, String> janitorTags = new HashMap<String, String>();
        janitorTags.put(JanitorMonkey.JANITOR_META_TAG, meta);
        LOGGER.info(String.format("Setting tag %s to '%s' for volume %s",
                JanitorMonkey.JANITOR_META_TAG, meta, volume.getVolumeId()));
        String prop = "simianarmy.volumeTagging.leashed";
        Event evt = null;
        if (config.getBoolOrElse(prop, true)) {
            LOGGER.info("Volume tagging monkey is leashed. No real change is made to the volume.");
        } else {
            try {
                awsClient.createTagsForResources(janitorTags, volume.getVolumeId());
                evt = context().recorder().newEvent(type(), EventTypes.TAGGING_JANITOR,
                        awsClient.region(), volume.getVolumeId());
                evt.addField(JanitorMonkey.JANITOR_META_TAG, meta);
            } catch (Exception e) {
                LOGGER.error(String.format("Failed to update the tag for volume %s", volume.getVolumeId()));
            }
        }
        return evt;
View Full Code Here

                        resource.getId(), resource.getResourceType(), resource.getExpectedTerminationTime()));
                resource.setState(CleanupState.MARKED);
                resource.setMarkTime(now);
                if (!leashed) {
                    if (recorder != null) {
                        Event evt = recorder.newEvent(Type.JANITOR, EventTypes.MARK_RESOURCE, region, resource.getId());
                        recorder.recordEvent(evt);
                    }
                    resourceTracker.addOrUpdate(resource);
                    postMark(resource);
                } else {
                    LOGGER.info(String.format(
                            "The janitor is leashed, no data change is made for marking the resource %s.",
                            resource.getId()));
                }
                markedResources.add(resource);
            } else if (trackedResource != null) {
                // The resource was marked and now the rule engine does not consider it as a cleanup candidate.
                // So the janitor needs to unmark the resource.
                LOGGER.info(String.format("Unmarking resource %s", resource.getId()));
                resource.setState(CleanupState.UNMARKED);
                if (!leashed) {
                    if (recorder != null) {
                        Event evt = recorder.newEvent(
                                Type.JANITOR, EventTypes.UNMARK_RESOURCE, region, resource.getId());
                        recorder.recordEvent(evt);
                    }
                    resourceTracker.addOrUpdate(resource);
                } else {
View Full Code Here

                LOGGER.info(String.format("Cleaning up resource %s of type %s",
                        markedResource.getId(), markedResource.getResourceType().name()));
                if (!leashed) {
                    try {
                        if (recorder != null) {
                            Event evt = recorder.newEvent(Type.JANITOR, EventTypes.CLEANUP_RESOURCE, region,
                                    markedResource.getId());
                            recorder.recordEvent(evt);
                        }
                        cleanup(markedResource);
                        markedResource.setActualTerminationTime(now);
View Full Code Here

TOP

Related Classes of com.netflix.simianarmy.MonkeyRecorder.Event

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.