/** * Performs rolling hot buckets for this index. */ public void rollHotBuckets() { ResponseMessage response = service.post(path + "/roll-hot-buckets"); assert(response.getStatus() == 200); }
/** {@inheritDoc} */ @Override public Entity refresh() { // Update any attribute values set by a setter method that has not // yet been written to the object. ResponseMessage response = service.get(path); assert(response.getStatus() == 200); AtomFeed feed; try { feed = AtomFeed.parseStream(response.getContent()); } catch (Exception e) { throw new RuntimeException(e); } int count = feed.entries.size(); if (count > 1) { throw new IllegalStateException("Expected 0 or 1 Atom entries; found " + feed.entries.size()); } AtomEntry entry = count == 0 ? null : feed.entries.get(0); load(entry); return this; }
int status = response.getStatus();
/** {@inheritDoc} */ @Override public ResourceCollection refresh() { items.clear(); ResponseMessage response = list(); assert(response.getStatus() == 200); AtomFeed feed = null; try { feed = AtomFeed.parseStream(response.getContent()); } catch (Exception e) { throw new RuntimeException(e); } load(feed); return this; }
/** * Creates a search. * <p> * <b>Note:</b> You can't create a "oneshot" search using this method. * Instead, use the {@link Service#oneshotSearch} method. * * @param query The search query. * @param args Additional arguments for this job (see {@link JobArgs}). * @return The unique search identifier (SID). */ public Job create(String query, Map args) { if (args != null && args.containsKey("exec_mode")) { if (args.get("exec_mode").equals("oneshot")) throw new RuntimeException(oneShotNotAllowed); } args = Args.create(args).add("search", query); ResponseMessage response = service.post(path, args); assert(response.getStatus() == 201); String sid = Xml.parse(response.getContent()) .getElementsByTagName("sid") .item(0) .getTextContent(); Job job = new Job(service, REST_PATH + "/" + sid); job.refresh(); return job; }
/** * Refreshes this job. * * @return The search job. */ @Override public Job refresh() { update(); ResponseMessage response = service.get(path); if (response.getStatus() == 204) { isReady = false; return this; } AtomEntry entry; try { entry = AtomEntry.parseStream(response.getContent()); } catch (Exception e) { throw new RuntimeException(e); } load(entry); if (getString("dispatchState").equals("QUEUED") || getString("dispatchState").equals("PARSING")) { isReady = false; } else { isReady = true; } return this; }
/** * Query Splunk for SPL queries corresponding to this pivot. * * @return a Pivot object encapsulating the returned queries. */ public Pivot pivot() { Service service = this.dataModelObject.getDataModel().getService(); Args args = new Args(); args.put("pivot_json", toJson()); if (this.accelerationNamespace != null) { args.put("namespace", this.accelerationNamespace); } ResponseMessage response = service.get( "datamodel/pivot/" + this.dataModelObject.getDataModel().getName(), args ); if (response.getStatus() != 200) { throw HttpException.create(response); } else { return Pivot.parseStream(service, response.getContent()); } } }