@Override public IOperatorNodePushable createPushRuntime(IHyracksTaskContext ctx, IRecordDescriptorProvider recordDescProvider, int partition, int nPartitions) throws HyracksDataException { return new IndexDropOperatorNodePushable(dataflowHelperFactory, options, ctx, partition); } }
private void dropNonExistingWithIfExists(IHyracksTaskContext ctx, IndexDataflowHelperFactory helperFactory) throws Exception { // Dropping non-existing index with if exists option should be successful dropFailed.set(false); IndexDropOperatorNodePushable dropNonExistingWithIfExistsOp = new IndexDropOperatorNodePushable(helperFactory, EnumSet.of(DropOption.IF_EXISTS), ctx, 0); try { dropNonExistingWithIfExistsOp.initialize(); } catch (HyracksDataException e) { e.printStackTrace(); dropFailed.set(true); } Assert.assertFalse(dropFailed.get()); } }
private void dropInUseWithWait(IHyracksTaskContext ctx, IndexDataflowHelperFactory helperFactory, IIndexDataflowHelper dataflowHelper) throws Exception { dropFailed.set(false); // drop with option wait for in-use should be successful once the index is closed final IndexDropOperatorNodePushable dropWithWaitOp = new IndexDropOperatorNodePushable(helperFactory, EnumSet.of(DropOption.IF_EXISTS, DropOption.WAIT_ON_IN_USE), ctx, 0); Thread dropThread = new Thread(() -> { try { dropWithWaitOp.initialize(); } catch (HyracksDataException e) { dropFailed.set(true); e.printStackTrace(); } }); dropThread.start(); // wait for the drop thread to start while (dropThread.getState() == Thread.State.NEW) { TimeUnit.MILLISECONDS.sleep(100); } // close the index to allow the drop to complete dataflowHelper.close(); dropThread.join(); Assert.assertFalse(dropFailed.get()); }
private void dropNonExisting(IHyracksTaskContext ctx, IndexDataflowHelperFactory helperFactory) throws Exception { dropFailed.set(false); // Dropping non-existing index IndexDropOperatorNodePushable dropNonExistingOp = new IndexDropOperatorNodePushable(helperFactory, EnumSet.noneOf(DropOption.class), ctx, 0); try { dropNonExistingOp.initialize(); } catch (HyracksDataException e) { e.printStackTrace(); Assert.assertEquals(ErrorCode.INDEX_DOES_NOT_EXIST, e.getErrorCode()); dropFailed.set(true); } Assert.assertTrue(dropFailed.get()); }
private void dropInUse(IHyracksTaskContext ctx, IndexDataflowHelperFactory helperFactory, IIndexDataflowHelper dataflowHelper) throws Exception { dropFailed.set(false); // open the index to make it in-use dataflowHelper.open(); // try to drop in-use index (should fail) IndexDropOperatorNodePushable dropInUseOp = new IndexDropOperatorNodePushable(helperFactory, EnumSet.noneOf(DropOption.class), ctx, 0); try { dropInUseOp.initialize(); } catch (HyracksDataException e) { e.printStackTrace(); Assert.assertEquals(ErrorCode.CANNOT_DROP_IN_USE_INDEX, e.getErrorCode()); dropFailed.set(true); } Assert.assertTrue(dropFailed.get()); }