@Test public void testRemoveNonExisting() throws Exception { createY(); TestUtils.assertMemoryLeak(() -> { try (CairoEngine engine = new CairoEngine(configuration)) { try { engine.remove(AllowAllCairoSecurityContext.INSTANCE, path, "x"); Assert.fail(); } catch (CairoException e) { TestUtils.assertContains(e.getMessage(), "remove failed"); } } }); }
public void remove( CairoSecurityContext securityContext, Path path, CharSequence tableName ) { securityContext.checkWritePermission(); if (lock(securityContext, tableName)) { try { path.of(configuration.getRoot()).concat(tableName).$(); if (!configuration.getFilesFacade().rmdir(path)) { int error = configuration.getFilesFacade().errno(); LOG.error().$("remove failed [tableName='").utf8(tableName).$("', error=").$(error).$(']').$(); throw CairoException.instance(error).put("Table remove failed"); } return; } finally { unlock(securityContext, tableName, null); } } throw CairoException.instance(configuration.getFilesFacade().errno()).put("Could not lock '").put(tableName).put('\''); }
CairoEngine implements Closeable { public void remove( CairoSecurityContext securityContext, Path path, CharSequence tableName ) { securityContext.checkWritePermission(); if (lock(securityContext, tableName)) { try { path.of(configuration.getRoot()).concat(tableName).$(); if (!configuration.getFilesFacade().rmdir(path)) { int error = configuration.getFilesFacade().errno(); LOG.error().$("remove failed [tableName='").utf8(tableName).$("', error=").$(error).$(']').$(); throw CairoException.instance(error).put("Table remove failed"); } return; } finally { unlock(securityContext, tableName, null); } } throw CairoException.instance(configuration.getFilesFacade().errno()).put("Could not lock '").put(tableName).put('\''); } }
CairoEngine implements Closeable { public void remove( CairoSecurityContext securityContext, Path path, CharSequence tableName ) { securityContext.checkWritePermission(); if (lock(securityContext, tableName)) { try { path.of(configuration.getRoot()).concat(tableName).$(); if (!configuration.getFilesFacade().rmdir(path)) { int error = configuration.getFilesFacade().errno(); LOG.error().$("remove failed [tableName='").utf8(tableName).$("', error=").$(error).$(']').$(); throw CairoException.instance(error).put("Table remove failed"); } return; } finally { unlock(securityContext, tableName, null); } } throw CairoException.instance(configuration.getFilesFacade().errno()).put("Could not lock '").put(tableName).put('\''); } CairoEngine(CairoConfiguration configuration); }
CairoEngine implements Closeable { public void remove( CairoSecurityContext securityContext, Path path, CharSequence tableName ) { securityContext.checkWritePermission(); if (lock(securityContext, tableName)) { try { path.of(configuration.getRoot()).concat(tableName).$(); if (!configuration.getFilesFacade().rmdir(path)) { int error = configuration.getFilesFacade().errno(); LOG.error().$("remove failed [tableName='").utf8(tableName).$("', error=").$(error).$(']').$(); throw CairoException.instance(error).put("Table remove failed"); } return; } finally { unlock(securityContext, tableName, null); } } throw CairoException.instance(configuration.getFilesFacade().errno()).put("Could not lock '").put(tableName).put('\''); } CairoEngine(CairoConfiguration configuration); @Override void close(); void creatTable(
            CairoSecurityContext securityContext,
            AppendMemory mem,
            Path path,
            TableStructure struct
    ); TableWriter getBackupWriter(
            CairoSecurityContext securityContext,
            CharSequence tableName,
            CharSequence backupDirName
    ); int getBusyReaderCount(); int getBusyWriterCount(); CairoConfiguration getConfiguration(); MessageBus getMessageBus(); PoolListener getPoolListener(); void setPoolListener(PoolListener poolListener); TableReader getReader(
            CairoSecurityContext securityContext,
            CharSequence tableName
    ); TableReader getReader(
            CairoSecurityContext securityContext,
            CharSequence tableName,
            long version
    ); int getStatus(
            CairoSecurityContext securityContext,
            Path path,
            CharSequence tableName,
            int lo,
            int hi
    ); int getStatus(
            CairoSecurityContext securityContext,
            Path path,
            CharSequence tableName
    ); Sequence getTelemetryPubSequence(); RingQueue<TelemetryTask> getTelemetryQueue(); SCSequence getTelemetrySubSequence(); TableWriter getWriter(
            CairoSecurityContext securityContext,
            CharSequence tableName
    ); Job getWriterMaintenanceJob(); boolean lock(
            CairoSecurityContext securityContext,
            CharSequence tableName
    ); boolean lockReaders(CharSequence tableName); boolean lockWriter(CharSequence tableName); boolean migrateNullFlag(CairoSecurityContext cairoSecurityContext, CharSequence tableName); boolean releaseAllReaders(); boolean releaseAllWriters(); boolean releaseInactive(); void remove(
            CairoSecurityContext securityContext,
            Path path,
            CharSequence tableName
    ); boolean removeDirectory(@Transient Path path, CharSequence dir); void rename(
            CairoSecurityContext securityContext,
            Path path,
            CharSequence tableName,
            Path otherPath,
            CharSequence newName
    ); void unlock(
            CairoSecurityContext securityContext,
            CharSequence tableName,
            @Nullable TableWriter writer
    ); void unlockReaders(CharSequence tableName); void unlockWriter(CharSequence tableName); }
CairoEngine implements Closeable { public void remove( CairoSecurityContext securityContext, Path path, CharSequence tableName ) { securityContext.checkWritePermission(); if (lock(securityContext, tableName)) { try { path.of(configuration.getRoot()).concat(tableName).$(); if (!configuration.getFilesFacade().rmdir(path)) { int error = configuration.getFilesFacade().errno(); LOG.error().$("remove failed [tableName='").utf8(tableName).$("', error=").$(error).$(']').$(); throw CairoException.instance(error).put("Table remove failed"); } return; } finally { unlock(securityContext, tableName, null); } } throw CairoException.instance(configuration.getFilesFacade().errno()).put("Could not lock '").put(tableName).put('\''); } CairoEngine(CairoConfiguration configuration); @Override void close(); void creatTable(
            CairoSecurityContext securityContext,
            AppendMemory mem,
            Path path,
            TableStructure struct
    ); TableWriter getBackupWriter(
            CairoSecurityContext securityContext,
            CharSequence tableName,
            CharSequence backupDirName
    ); int getBusyReaderCount(); int getBusyWriterCount(); CairoConfiguration getConfiguration(); MessageBus getMessageBus(); PoolListener getPoolListener(); void setPoolListener(PoolListener poolListener); TableReader getReader(
            CairoSecurityContext securityContext,
            CharSequence tableName
    ); TableReader getReader(
            CairoSecurityContext securityContext,
            CharSequence tableName,
            long version
    ); int getStatus(
            CairoSecurityContext securityContext,
            Path path,
            CharSequence tableName,
            int lo,
            int hi
    ); int getStatus(
            CairoSecurityContext securityContext,
            Path path,
            CharSequence tableName
    ); Sequence getTelemetryPubSequence(); RingQueue<TelemetryTask> getTelemetryQueue(); SCSequence getTelemetrySubSequence(); TableWriter getWriter(
            CairoSecurityContext securityContext,
            CharSequence tableName
    ); Job getWriterMaintenanceJob(); boolean lock(
            CairoSecurityContext securityContext,
            CharSequence tableName
    ); boolean lockReaders(CharSequence tableName); boolean lockWriter(CharSequence tableName); boolean migrateNullFlag(CairoSecurityContext cairoSecurityContext, CharSequence tableName); boolean releaseAllReaders(); boolean releaseAllWriters(); boolean releaseInactive(); void remove(
            CairoSecurityContext securityContext,
            Path path,
            CharSequence tableName
    ); boolean removeDirectory(@Transient Path path, CharSequence dir); void rename(
            CairoSecurityContext securityContext,
            Path path,
            CharSequence tableName,
            Path otherPath,
            CharSequence newName
    ); void unlock(
            CairoSecurityContext securityContext,
            CharSequence tableName,
            @Nullable TableWriter writer
    ); void unlockReaders(CharSequence tableName); void unlockWriter(CharSequence tableName);  }