Package com.streamreduce.core.model

Examples of com.streamreduce.core.model.InventoryItem


                    // Move on to the next activity entry
                    continue;
                }

                InventoryItem inventoryItem = inventoryItemMap.get(projectKey);

                // This can happen if the activity is from a project, or Jira Studio product, not associated with a
                // project in our inventory system.  (A good example of this is wiki changes.  Each Jira Studio project
                // gets its own wiki but you can create new wiki spaces that are not associated with a Jira Studio
                // project and will end up without an inventory item in our system.)
View Full Code Here


        try {
            List<JSONObject> jsonInventoryList = client.checks();

            for (Iterator<JSONObject> i = jsonInventoryList.iterator(); i.hasNext();) {
                JSONObject jsonInventory = i.next();
                InventoryItem inventoryItem = inventoryItemMap.get(jsonInventory.getString("id"));

                if (inventoryItem == null) {
                    continue;
                }

                // the connection may not have been tested yet from Pingdom
                if (!jsonInventory.containsKey("lasttesttime")) {
                    continue;
                }

                Date lastTestTime = new DateTime().withMillis(0).plusSeconds(jsonInventory.getInt("lasttesttime")).toDate();
                if (lastActivityPoll != null && lastActivityPoll.after(lastTestTime)) {
                    continue;
                }

                lastActivityPoll = lastTestTime.after(lastActivityPoll) ? lastTestTime : lastActivityPoll;

                Map<String, Object> eventContext = new HashMap<>();

                eventContext.put("activityPubDate", lastTestTime);
                eventContext.put("activityTitle", String.format("Service check %s (%s) has a response time of %dms.",
                        jsonInventory.getString("name"),
                        jsonInventory.getString("type").toUpperCase(),
                        jsonInventory.getInt("lastresponsetime")));
                eventContext.put("payload", jsonInventory);

                if (jsonInventory.containsKey("lastresponsetime")) {
                    eventContext.put("lastResponseTime", jsonInventory.getInt("lastresponsetime"));
                }

                Event event = eventService.createEvent(EventId.ACTIVITY,
                                                       inventoryItem,
                                                       eventContext);

                PingdomEntryDetails details = new PingdomEntryDetails.Builder()
                        .lastErrorTime(jsonInventory.containsKey("lasterrortime") ? jsonInventory.getInt("lasterrortime") : 0)
                        .lastResponseTime(jsonInventory.containsKey("lastresponsetime") ? jsonInventory.getInt("lastresponsetime") : 0)
                        .lastTestTime(jsonInventory.getInt("lasttesttime"))
                        .checkCreated(jsonInventory.getInt("created"))
                        .resolution(jsonInventory.getInt("resolution"))
                        .status(jsonInventory.getString("status"))
                        .build();

                // Create a new message to be delivered to inboxes
                messageService.sendAccountMessage(event,
                        inventoryItem,
                        connection,
                        lastTestTime.getTime(),
                        MessageType.ACTIVITY,
                        inventoryItem.getHashtags(),
                        details);
            }

            // Update the connection's last polling time
            connection.setLastActivityPollDate(new Date(lastActivityPoll.getTime() + 1));
View Full Code Here

TOP

Related Classes of com.streamreduce.core.model.InventoryItem

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.