Refine search
@Override public long performEntityCount() { //TODO, this really needs to be a task that writes this data somewhere since this will get //progressively slower as the system expands return (Long) getAllEntitiesObservable().countLong().toBlocking().last(); }
List<MarkedEdge> edgeList = graphManager.loadEdgeVersions(searchByEdge).toList().toBlocking().last(); boolean timestampAllowsDelete = false; if (edgeList.size() > 0) { graphManager.markEdge(edge).toBlocking().lastOrDefault(null); edgesDeleted++; graphManager.deleteEdge(firstEdge).toBlocking().lastOrDefault(null);
/** * Deletes a resource group. * When you delete a resource group, all of its resources are also deleted. Deleting a resource group deletes all of its template deployments and currently stored operations. * * @param resourceGroupName The name of the resource group to delete. The name is case insensitive. * @throws IllegalArgumentException thrown if parameters fail the validation * @throws CloudException thrown if the request is rejected by server * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent */ public void delete(String resourceGroupName) { deleteWithServiceResponseAsync(resourceGroupName).toBlocking().last().body(); }
@Override public Set<String> getConnectionsAsTarget( final EntityRef entityRef ) { Preconditions.checkNotNull( entityRef, "entityRef cannot be null" ); final GraphManager graphManager = graphManagerFactory.createEdgeManager( applicationScope ); final SearchEdgeType searchByEdgeType = createConnectionTypeSearch( entityRef.asId() ); return graphManager.getEdgeTypesToTarget(searchByEdgeType).map( edgeName -> getConnectionNameFromEdgeName( edgeName ) ) .collect( () -> new HashSet<String>( ), ( r, s ) -> r.add(s) ).toBlocking().last(); }
/** * Deletes a resource by ID. * * @param resourceId The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name} * @param apiVersion The API version to use for the operation. * @throws IllegalArgumentException thrown if parameters fail the validation * @throws CloudException thrown if the request is rejected by server * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent */ public void deleteById(String resourceId, String apiVersion) { deleteByIdWithServiceResponseAsync(resourceId, apiVersion).toBlocking().last().body(); }
@Test public void writeLoadDelete() { ApplicationScope context = new ApplicationScopeImpl( new SimpleId( "organization" ) ); Entity newEntity = new Entity( new SimpleId( "test" ) ); EntityCollectionManager manager = factory.createCollectionManager( context ); Observable<Entity> observable = manager.write( newEntity, null ); Entity createReturned = observable.toBlocking().lastOrDefault( null ); assertNotNull( "Id was assigned", createReturned.getId() ); Observable<Entity> loadObservable = manager.load( createReturned.getId() ); Entity loadReturned = loadObservable.toBlocking().lastOrDefault( null ); assertEquals( "Same value", createReturned, loadReturned ); manager.mark( createReturned.getId(), null ).toBlocking().last(); loadObservable = manager.load( createReturned.getId() ); //load may return null, use last or default loadReturned = loadObservable.toBlocking().lastOrDefault( null ); assertNull( "Entity was deleted", loadReturned ); }
@Override public Set<String> getConnectionsAsSource( final EntityRef entityRef ) { Preconditions.checkNotNull(entityRef, "entityRef cannot be null"); final GraphManager graphManager = graphManagerFactory.createEdgeManager( applicationScope ); final SearchEdgeType searchByEdgeType = createConnectionTypeSearch( entityRef.asId() ); return graphManager.getEdgeTypesFromSource( searchByEdgeType ).map( edgeName -> getConnectionNameFromEdgeName( edgeName ) ) .collect( () -> new HashSet<String>(), ( r, s ) -> r.add( s ) ).toBlocking().last(); }
/** * Deletes the specified DDoS protection plan. * * @param resourceGroupName The name of the resource group. * @param ddosProtectionPlanName The name of the DDoS protection plan. * @throws IllegalArgumentException thrown if parameters fail the validation * @throws CloudException thrown if the request is rejected by server * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent */ public void delete(String resourceGroupName, String ddosProtectionPlanName) { deleteWithServiceResponseAsync(resourceGroupName, ddosProtectionPlanName).toBlocking().last().body(); }
Entity createReturned = manager.write( entity, null ).toBlocking().lastOrDefault( null ); newEntity.setField( new IntegerField( "counter", i ) ); final Entity returnedEntity = manager.write( newEntity, null ).toBlocking().last(); final Entity lastVersion = manager.load( entityId ).toBlocking().last(); final List<MvccLogEntry> entries = manager.getVersions( entityId ).toList().toBlocking().last(); .toBlocking().last(); final List<MvccLogEntry> postDeleteEntries = manager.getVersions( entityId ).toList().toBlocking().last();
@Override public Set<String> getConnectionTypes( boolean filterConnection ) throws Exception { final GraphManager gm = managerCache.getGraphManager( applicationScope ); Observable<String> edges = gm.getEdgeTypesFromSource( new SimpleSearchEdgeType( cpHeadEntity.getId(), null, null ) ); return edges.collect( () -> new HashSet<String>(), ( edgeSet, edge ) -> { edgeSet.add( CpNamingUtils.getNameFromEdgeType( edge ) ); } ).toBlocking().last(); }
/** * Deletes the specified network security group. * * @param resourceGroupName The name of the resource group. * @param networkSecurityGroupName The name of the network security group. * @throws IllegalArgumentException thrown if parameters fail the validation * @throws CloudException thrown if the request is rejected by server * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent */ public void delete(String resourceGroupName, String networkSecurityGroupName) { deleteWithServiceResponseAsync(resourceGroupName, networkSecurityGroupName).toBlocking().last().body(); }
@Test public void writeMultiget() { final ApplicationScope context = new ApplicationScopeImpl( new SimpleId( "organization" ) ); final EntityCollectionManager manager = factory.createCollectionManager( context ); final int multigetSize = serializationFig.getMaxLoadSize(); final List<Entity> writtenEntities = new ArrayList<>( multigetSize ); final List<Id> entityIds = new ArrayList<>( multigetSize ); for ( int i = 0; i < multigetSize; i++ ) { final Entity entity = new Entity( new SimpleId( "test" ) ); final Entity written = manager.write( entity, null ).toBlocking().last(); writtenEntities.add( written ); entityIds.add( written.getId() ); } final EntitySet entitySet = manager.load( entityIds ).toBlocking().lastOrDefault( null ); assertNotNull( entitySet ); assertEquals( multigetSize, entitySet.size() ); assertFalse( entitySet.isEmpty() ); /** * Validate every element exists */ for ( int i = 0; i < multigetSize; i++ ) { final Entity expected = writtenEntities.get( i ); final MvccEntity returned = entitySet.getEntity( expected.getId() ); assertEquals( "Same entity returned", expected, returned.getEntity().get() ); } }
@Override public Set<String> getCollectionIndexes( String collectionName ) throws Exception { GraphManager gm = managerCache.getGraphManager( applicationScope ); String edgeTypePrefix = CpNamingUtils.getEdgeTypeFromCollectionName( collectionName ); if (logger.isTraceEnabled()) { logger.trace("getCollectionIndexes(): Searching for edge type prefix {} to target {}:{}", edgeTypePrefix, cpHeadEntity.getId().getType(), cpHeadEntity.getId().getUuid() ); } Observable<Set<String>> types = gm.getEdgeTypesFromSource( new SimpleSearchEdgeType( cpHeadEntity.getId(), edgeTypePrefix, null ) ) .collect( () -> new HashSet<>(), ( set, type ) -> set.add( type ) ); return types.toBlocking().last(); }
/** * Deletes the specified application security group. * * @param resourceGroupName The name of the resource group. * @param applicationSecurityGroupName The name of the application security group. * @throws IllegalArgumentException thrown if parameters fail the validation * @throws CloudException thrown if the request is rejected by server * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent */ public void delete(String resourceGroupName, String applicationSecurityGroupName) { deleteWithServiceResponseAsync(resourceGroupName, applicationSecurityGroupName).toBlocking().last().body(); }
@Test public void testGetIdField() throws Exception { ApplicationScope context = new ApplicationScopeImpl( new SimpleId( "organization" ) ); EntityCollectionManager manager = factory.createCollectionManager( context ); // create an entity of type "item" with a unique_id field value = 1 Entity entity1 = new Entity( new SimpleId( "item" ) ); entity1.setField( new StringField( "unique_id", "1", true ) ); manager.write( entity1, null ).toBlocking().last(); final Observable<Id> idObs = manager.getIdField( "item", new StringField( "unique_id", "1" ) ); Id id = idObs.toBlocking().lastOrDefault( null ); assertEquals( entity1.getId(), id ); // create an entity of type "deleted_item" with a unique_id field value = 1 Entity entity2 = new Entity( new SimpleId( "deleted_item" ) ); entity2.setField( new StringField( "unique_id", "1", true ) ); manager = factory.createCollectionManager( context ); manager.write( entity2, null ).toBlocking().last(); final Observable<Id> id2Obs = manager.getIdField( "deleted_item", new StringField( "unique_id", "1" ) ); Id id2 = id2Obs.toBlocking().lastOrDefault( null ); assertEquals( entity2.getId(), id2 ); }
private List<Integer> checkResults(final List<StreamResult> streamResults){ List<Integer> combined = new ArrayList<>(); List<Integer> integers = streamResults.stream().filter( streamResult -> streamResult.getNumber() > 0) .map(streamResult -> { combined.add(streamResult.getNumber()); return streamResult.getNumber(); }) .collect(Collectors.toList()); Observable.from(combined).map( s -> { logger.info("Doing work in another observable with Integer: {}", s); return s; }).toBlocking().last(); return integers; }
/** * Deletes the specified express route circuit. * * @param resourceGroupName The name of the resource group. * @param circuitName The name of the express route circuit. * @throws IllegalArgumentException thrown if parameters fail the validation * @throws CloudException thrown if the request is rejected by server * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent */ public void delete(String resourceGroupName, String circuitName) { deleteWithServiceResponseAsync(resourceGroupName, circuitName).toBlocking().last().body(); }
gm.writeEdge( edge1 ).toBlocking().last(); gm.writeEdge( edge2 ).toBlocking().last(); gm.markEdge( edge1 ).toBlocking().last(); gm.deleteEdge( edge1 ).toBlocking().last();
@Override public long getApplicationSize(ApplicationScope applicationScope) { final IndexLocationStrategy indexLocationStrategy = indexLocationStrategyFactory.getIndexLocationStrategy(applicationScope); EntityIndex entityIndex = entityIndexFactory.createEntityIndex(indexLocationStrategy); GraphManager graphManager = graphManagerFactory.createEdgeManager(applicationScope); Long sum = ObservableTimer.time( MathObservable.sumLong( graphManager.getEdgeTypesFromSource(new SimpleSearchEdgeType(applicationScope.getApplication(), CpNamingUtils.EDGE_COLL_PREFIX, Optional.<String>absent())) .map(type -> CpNamingUtils.createCollectionSearchEdge(applicationScope.getApplication(), type)) .map(edge -> entityIndex.getTotalEntitySizeInBytes(edge)) ), sumTimer).toBlocking().last(); return sum.longValue(); }
/** * The operation to delete a virtual machine. * * @param resourceGroupName The name of the resource group. * @param vmName The name of the virtual machine. * @throws IllegalArgumentException thrown if parameters fail the validation * @throws CloudException thrown if the request is rejected by server * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent */ public void delete(String resourceGroupName, String vmName) { deleteWithServiceResponseAsync(resourceGroupName, vmName).toBlocking().last().body(); }