/** * {@inheritDoc} */ @Override public Optional<IndexSetConfig> findOne(DBQuery.Query query) { return Optional.ofNullable(collection.findOne(query)); }
public Optional<DataAdapterDto> get(String idOrName) { try { return Optional.ofNullable(db.findOneById(new ObjectId(idOrName))); } catch (IllegalArgumentException e) { // not an ObjectId, try again with name return Optional.ofNullable(db.findOne(DBQuery.is("name", idOrName))); } }
public Optional<LookupTableDto> get(String idOrName) { try { return Optional.ofNullable(db.findOneById(new ObjectId(idOrName))); } catch (IllegalArgumentException e) { // not an ObjectId, try again with name return Optional.ofNullable(db.findOne(DBQuery.is("name", idOrName))); } }
/** * {@inheritDoc} */ @Override public Optional<IndexSetConfig> get(ObjectId id) { final DBQuery.Query query = DBQuery.is("_id", id); final IndexSetConfig indexSetConfig = collection.findOne(query); return Optional.ofNullable(indexSetConfig); }
public Optional<IndexFieldTypesDTO> get(String idOrIndexName) { try { return Optional.ofNullable(db.findOneById(new ObjectId(idOrIndexName))); } catch (IllegalArgumentException e) { // Not an ObjectId, try again with index_name return Optional.ofNullable(db.findOne(DBQuery.is(IndexFieldTypesDTO.FIELD_INDEX_NAME, idOrIndexName))); } }
public Optional<GrokPattern> loadByName(String name) { final GrokPattern pattern = dbCollection.findOne(DBQuery.is("name", name)); return Optional.ofNullable(pattern); }
public Optional<CacheDto> get(String idOrName) { try { return Optional.ofNullable(db.findOneById(new ObjectId(idOrName))); } catch (IllegalArgumentException e) { // not an ObjectId, try again with name return Optional.ofNullable(db.findOne(DBQuery.is("name", idOrName))); } }
@Nullable public Collector findByName(String name) { return db.findOne(DBQuery.is("name", name)); }
@Nullable public Collector find(String id) { return db.findOne(DBQuery.is("_id", id)); }
@Override public RoleImpl load(String roleName) throws NotFoundException { final RoleImpl role = dbCollection.findOne(is(NAME_LOWER, roleName.toLowerCase(Locale.ENGLISH))); if (role == null) { throw new NotFoundException("No role found with name " + roleName); } return role; }
public Optional<ContentPack> findByIdAndRevision(ModelId id, int revision) { final DBQuery.Query query = DBQuery.is(Identified.FIELD_META_ID, id).is(Revisioned.FIELD_META_REVISION, revision); return Optional.ofNullable(dbCollection.findOne(query)); }
@Override public PipelineConnections load(String streamId) throws NotFoundException { final PipelineConnections oneById = dbCollection.findOne(DBQuery.is("stream_id", streamId)); if (oneById == null) { throw new NotFoundException("No pipeline connections with for stream " + streamId); } return oneById; }
@Override public RuleDao loadByName(String name) throws NotFoundException { final DBQuery.Query query = DBQuery.is("title", name); final RuleDao rule = dbCollection.findOne(query); if (rule == null) { throw new NotFoundException("No rule with name " + name); } return rule; }
@Override public PipelineDao loadByName(String name) throws NotFoundException { final DBQuery.Query query = DBQuery.is("title", name); final PipelineDao pipeline = dbCollection.findOne(query); if (pipeline == null) { throw new NotFoundException("No pipeline with name " + name); } return pipeline; }
@Override public <T> T get(String key, Class<T> type) { ClusterConfig config = dbCollection.findOne(DBQuery.is("type", key)); if (config == null) { LOG.debug("Couldn't find cluster config of type {}", key); return null; } T result = extractPayload(config.payload(), type); if (result == null) { LOG.error("Couldn't extract payload from cluster config (type: {})", key); } return result; }
@Nullable public Collector findByNameExcludeId(String name, String id) { return db.findOne( DBQuery.and( DBQuery.is("name", name), DBQuery.notEquals("_id", id)) ); }
@Nullable public Collector findByNameAndOs(String name, String operatingSystem) { return db.findOne( DBQuery.and( DBQuery.is("name", name), DBQuery.is("node_operating_system", operatingSystem)) ); }
public CollectorActions findActionBySidecar(String sidecarId, boolean remove) { if (remove) { return dbCollection.findAndRemove(DBQuery.is("sidecar_id", sidecarId)); } else { return dbCollection.findOne(DBQuery.is("sidecar_id", sidecarId)); } } }
@Override public IndexRange get(String index) throws NotFoundException { final DBQuery.Query query = DBQuery.and( DBQuery.notExists("start"), DBQuery.is(IndexRange.FIELD_INDEX_NAME, index)); final MongoIndexRange indexRange = collection.findOne(query); if (indexRange == null) { throw new NotFoundException("Index range for index <" + index + "> not found."); } return indexRange; }
@Override public PipelineConnections save(PipelineConnections connections) { PipelineConnections existingConnections = dbCollection.findOne(DBQuery.is("stream_id", connections.streamId())); if (existingConnections == null) { existingConnections = PipelineConnections.create(null, connections.streamId(), Collections.emptySet()); } final PipelineConnections toSave = existingConnections.toBuilder() .pipelineIds(connections.pipelineIds()).build(); final WriteResult<PipelineConnections, String> save = dbCollection.save(toSave); final PipelineConnections savedConnections = save.getSavedObject(); clusterBus.post(PipelineConnectionsChangedEvent.create(savedConnections.streamId(), savedConnections.pipelineIds())); return savedConnections; }