protected Transaction newTransaction( LoginContext loginContext ) throws TransactionFailureException { transaction = kernel.beginTransaction( implicit, loginContext ); return transaction; }
public IndexDescriptor createConstraintIndex( final SchemaDescriptor schema, String provider ) { try ( Transaction transaction = kernelSupplier.get().beginTransaction( implicit, AUTH_DISABLED ) ) { IndexDescriptor index = ((KernelTransaction) transaction).indexUniqueCreate( schema, provider ); transaction.success(); return index; } catch ( TransactionFailureException | SchemaKernelException e ) { throw new RuntimeException( e ); } } }
@Override public synchronized int createToken( String name ) throws KernelException { Kernel kernel = kernelSupplier.get(); try ( Transaction tx = kernel.beginTransaction( Type.implicit, LoginContext.AUTH_DISABLED ) ) { int id = createKey( tx, name ); tx.success(); return id; } }
@Override public synchronized void createTokens( String[] names, int[] ids, IntPredicate filter ) throws KernelException { Kernel kernel = kernelSupplier.get(); try ( Transaction tx = kernel.beginTransaction( Type.implicit, LoginContext.AUTH_DISABLED ) ) { for ( int i = 0; i < ids.length; i++ ) { if ( filter.test( i ) ) { ids[i] = createKey( tx, names[i] ); } } tx.success(); } }
static void putTokenCounts( Map<String,Object> metaData, Kernel kernel ) { try ( Transaction tx = kernel.beginTransaction( Transaction.Type.explicit, LoginContext.AUTH_DISABLED ) ) { TokenRead tokens = tx.tokenRead(); metaData.put( "labelCount", tokens.labelCount() ); metaData.put( "relationshipTypeCount", tokens.relationshipTypeCount() ); metaData.put( "propertyKeyCount", tokens.propertyKeyCount() ); tx.success(); } catch ( TransactionFailureException e ) { throw new UnsupportedOperationException( "How to handle errors?" ); } } }
protected Transaction beginTransaction() throws TransactionFailureException { Kernel kernel = testSupport.kernelToTest(); return kernel.beginTransaction( Transaction.Type.implicit, LoginContext.AUTH_DISABLED ); }
protected SchemaWrite schemaWriteInNewTransaction() throws KernelException { transaction = kernel.beginTransaction( implicit, AUTH_DISABLED ); return transaction.schemaWrite(); }
static Stream<RetrieveResult> retrieve( Kernel kernel ) throws TransactionFailureException { try ( Transaction tx = kernel.beginTransaction( Transaction.Type.explicit, LoginContext.AUTH_DISABLED ) ) { TokenRead tokens = tx.tokenRead(); List<String> labels = new ArrayList<>( tokens.labelCount() ); tokens.labelsGetAllTokens().forEachRemaining( t -> labels.add( t.name() ) ); List<String> relationshipTypes = new ArrayList<>( tokens.relationshipTypeCount() ); tokens.relationshipTypesGetAllTokens().forEachRemaining( t -> relationshipTypes.add( t.name() ) ); List<String> propertyKeys = new ArrayList<>( tokens.propertyKeyCount() ); tokens.propertyKeyGetAllTokens().forEachRemaining( t -> propertyKeys.add( t.name() ) ); Map<String,Object> data = new HashMap<>(); data.put( "labels", labels ); data.put( "relationshipTypes", relationshipTypes ); data.put( "propertyKeys", propertyKeys ); return Stream.of( new RetrieveResult( Sections.TOKENS, data ) ); } }
protected Transaction beginTransaction() throws TransactionFailureException { Kernel kernel = testSupport.kernelToTest(); return kernel.beginTransaction( Transaction.Type.implicit, LoginContext.AUTH_DISABLED ); }
protected Transaction newTransaction() throws TransactionFailureException { transaction = kernel.beginTransaction( implicit, AnonymousContext.read() ); return transaction; }
private void newTransaction() throws KernelException { if ( transaction != null ) { fail( "tx already opened" ); } transaction = kernel.beginTransaction( KernelTransaction.Type.implicit, LoginContext.AUTH_DISABLED ); }
/** * You MUST hold a schema write lock before you call this method. */ public void dropUniquenessConstraintIndex( IndexDescriptor descriptor ) throws TransactionFailureException { try ( Transaction transaction = kernelSupplier.get().beginTransaction( implicit, AUTH_DISABLED ); Statement ignore = ((KernelTransaction)transaction).acquireStatement() ) { ((KernelTransactionImplementation) transaction).txState().indexDoDrop( descriptor ); transaction.success(); } }
static Stream<RetrieveResult> retrieve( Kernel kernel, Anonymizer anonymizer ) throws TransactionFailureException, IndexNotFoundKernelException { try ( Transaction tx = kernel.beginTransaction( Transaction.Type.explicit, LoginContext.AUTH_DISABLED ) ) { TokenRead tokens = tx.tokenRead(); Read read = tx.dataRead(); Map<String,Object> data = new HashMap<>(); data.put( "nodes", nodeCounts( tokens, read, anonymizer ) ); data.put( "relationships", relationshipCounts( tokens, read, anonymizer ) ); data.put( "indexes", indexes( tokens, tx.schemaRead(), anonymizer ) ); data.put( "constraints", constraints( tokens, tx.schemaRead(), anonymizer ) ); return Stream.of( new RetrieveResult( Sections.GRAPH_COUNTS, data ) ); } }
protected TokenWrite tokenWriteInNewTransaction() throws KernelException { transaction = kernel.beginTransaction( implicit, AnonymousContext.writeToken() ); return transaction.tokenWrite(); }
protected Procedures procsSchema() throws TransactionFailureException { transaction = kernel.beginTransaction( KernelTransaction.Type.implicit, AnonymousContext.full() ); return transaction.procedures(); }
private void awaitSchemaStateCleared( String keyForProbing ) throws TransactionFailureException { try ( Transaction transaction = kernel.beginTransaction( implicit, AUTH_DISABLED ) ) { while ( transaction.schemaRead().schemaStateGetOrCreate( keyForProbing, ignored -> null ) != null ) { LockSupport.parkNanos( MILLISECONDS.toNanos( 10 ) ); } transaction.success(); } }
protected Procedures procs() throws TransactionFailureException { transaction = kernel.beginTransaction( implicit, AnonymousContext.read() ); return transaction.procedures(); }
private String commitToSchemaState( String key, String value ) throws TransactionFailureException { try ( Transaction transaction = kernel.beginTransaction( implicit, AUTH_DISABLED ) ) { String result = getOrCreateFromState( transaction, key, value ); transaction.success(); return result; } }
private Transaction transaction() throws TransactionFailureException { DependencyResolver resolver = this.db.getDependencyResolver(); return resolver.resolveDependency( Kernel.class ).beginTransaction( implicit, LoginContext.AUTH_DISABLED ); }
protected Write dataWriteInNewTransaction() throws KernelException { transaction = kernel.beginTransaction( implicit, AnonymousContext.write() ); return transaction.dataWrite(); }