@Test public void testRenameNonExisting() throws Exception { TestUtils.assertMemoryLeak(() -> { try (TableModel model = new TableModel(configuration, "z", PartitionBy.NONE) .col("a", ColumnType.INT)) { CairoTestUtils.create(model); } try (CairoEngine engine = new CairoEngine(configuration)) { engine.rename(AllowAllCairoSecurityContext.INSTANCE, path, "x", otherPath, "y"); Assert.fail(); } catch (CairoException e) { TestUtils.assertContains(e.getMessage(), "does not exist"); } }); }
public void rename( CairoSecurityContext securityContext, Path path, CharSequence tableName, Path otherPath, CharSequence newName ) { securityContext.checkWritePermission(); if (lock(securityContext, tableName)) { try { rename0(path, tableName, otherPath, newName); } finally { unlock(securityContext, tableName, null); } } else { LOG.error().$("cannot lock and rename [from='").$(tableName).$("', to='").$(newName).$("']").$(); throw CairoException.instance(0).put("Cannot lock [table=").put(tableName).put(']'); } }
CairoEngine implements Closeable { public void rename( CairoSecurityContext securityContext, Path path, CharSequence tableName, Path otherPath, CharSequence newName ) { securityContext.checkWritePermission(); if (lock(securityContext, tableName)) { try { rename0(path, tableName, otherPath, newName); } finally { unlock(securityContext, tableName, null); } } else { LOG.error().$("cannot lock and rename [from='").$(tableName).$("', to='").$(newName).$("']").$(); throw CairoException.instance(0).put("Cannot lock [table=").put(tableName).put(']'); } } }
CairoEngine implements Closeable { public void rename( CairoSecurityContext securityContext, Path path, CharSequence tableName, Path otherPath, CharSequence newName ) { securityContext.checkWritePermission(); if (lock(securityContext, tableName)) { try { rename0(path, tableName, otherPath, newName); } finally { unlock(securityContext, tableName, null); } } else { LOG.error().$("cannot lock and rename [from='").$(tableName).$("', to='").$(newName).$("']").$(); throw CairoException.instance(0).put("Cannot lock [table=").put(tableName).put(']'); } } CairoEngine(CairoConfiguration configuration); }
CairoEngine implements Closeable { public void rename( CairoSecurityContext securityContext, Path path, CharSequence tableName, Path otherPath, CharSequence newName ) { securityContext.checkWritePermission(); if (lock(securityContext, tableName)) { try { rename0(path, tableName, otherPath, newName); } finally { unlock(securityContext, tableName, null); } } else { LOG.error().$("cannot lock and rename [from='").$(tableName).$("', to='").$(newName).$("']").$(); throw CairoException.instance(0).put("Cannot lock [table=").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 rename( CairoSecurityContext securityContext, Path path, CharSequence tableName, Path otherPath, CharSequence newName ) { securityContext.checkWritePermission(); if (lock(securityContext, tableName)) { try { rename0(path, tableName, otherPath, newName); } finally { unlock(securityContext, tableName, null); } } else { LOG.error().$("cannot lock and rename [from='").$(tableName).$("', to='").$(newName).$("']").$(); throw CairoException.instance(0).put("Cannot lock [table=").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);  }