vldpyatkov commented on a change in pull request #704:
URL: https://github.com/apache/ignite-3/pull/704#discussion_r820147762



##########
File path: 
modules/table/src/main/java/org/apache/ignite/internal/table/distributed/TableManager.java
##########
@@ -199,212 +199,161 @@ public TableManager(
     /** {@inheritDoc} */
     @Override
     public void start() {
-        tablesCfg.tables()
-                .listenElements(new ConfigurationNamedListListener<>() {
-                    @Override
-                    public CompletableFuture<?> 
onCreate(ConfigurationNotificationEvent<TableView> ctx) {
-                        if (!busyLock.enterBusy()) {
-                            String tblName = ctx.newValue().name();
-                            UUID tblId = ((ExtendedTableView) 
ctx.newValue()).id();
-
-                            fireEvent(TableEvent.CREATE,
-                                    new 
TableEventParameters(ctx.storageRevision(), tblId, tblName),
-                                    new NodeStoppingException()
-                            );
-
-                            return CompletableFuture.failedFuture(new 
NodeStoppingException());
-                        }
+        ((ExtendedTableConfiguration) 
tablesCfg.tables().any()).schemas().listenElements(new 
ConfigurationNamedListListener<>() {
+            @Override
+            public CompletableFuture<?> 
onCreate(ConfigurationNotificationEvent<SchemaView> schemasCtx) {
 
-                        try {
-                            onTableCreateInternal(ctx);
-                        } finally {
-                            busyLock.leaveBusy();
-                        }
+                long causalityToken = schemasCtx.storageRevision();
 
-                        return CompletableFuture.completedFuture(null);
-                    }
+                ExtendedTableConfiguration tblCfg = 
(ExtendedTableConfiguration) schemasCtx.config(TableConfiguration.class);
 
-                    /**
-                     * Method for handle a table configuration event.
-                     *
-                     * @param ctx Configuration event.
-                     */
-                    private void 
onTableCreateInternal(ConfigurationNotificationEvent<TableView> ctx) {
-                        String tblName = ctx.newValue().name();
-                        UUID tblId = ((ExtendedTableView) ctx.newValue()).id();
-
-                        // Empty assignments might be a valid case if tables 
are created from within cluster init HOCON
-                        // configuration, which is not supported now.
-                        assert ((ExtendedTableView) 
ctx.newValue()).assignments() != null :
-                                IgniteStringFormatter.format("Table [id={}, 
name={}] has empty assignments.", tblId, tblName);
-
-                        // TODO: IGNITE-16369 Listener with any placeholder 
should be used instead.
-                        ((ExtendedTableConfiguration) 
tablesCfg.tables().get(tblName)).schemas()
-                                .listenElements(new 
ConfigurationNamedListListener<>() {
-                                    @Override
-                                    public CompletableFuture<?> 
onCreate(ConfigurationNotificationEvent<SchemaView> schemasCtx) {
-                                        long causalityToken = 
schemasCtx.storageRevision();
-
-                                        if (!busyLock.enterBusy()) {
-                                            fireEvent(
-                                                    TableEvent.ALTER,
-                                                    new 
TableEventParameters(causalityToken, tblId, tblName),
-                                                    new NodeStoppingException()
-                                            );
-
-                                            return 
CompletableFuture.failedFuture(new NodeStoppingException());
-                                        }
+                UUID tblId = tblCfg.id().value();
 
-                                        try {
-                                            // Avoid calling listener 
immediately after the listener completes to create the current table.
-                                            // FIXME: 
https://issues.apache.org/jira/browse/IGNITE-16369
-                                            if (ctx.storageRevision() != 
schemasCtx.storageRevision()) {
-                                                return 
tablesByIdVv.get(causalityToken).thenAccept(tablesById -> {
-                                                    TableImpl table = 
tablesById.get(tblId);
+                String tblName = tblCfg.name().value();
 
-                                                    ((SchemaRegistryImpl) 
table.schemaView())
-                                                            
.onSchemaRegistered(
-                                                                    
SchemaSerializerImpl.INSTANCE.deserialize(
-                                                                            
(schemasCtx.newValue().schema())));
+                SchemaDescriptor schemaDescriptor = 
SchemaSerializerImpl.INSTANCE.deserialize((schemasCtx.newValue().schema()));
 
-                                                    
fireEvent(TableEvent.ALTER, new TableEventParameters(causalityToken,
-                                                            table), null);
+                if (!busyLock.enterBusy()) {
+                    if (schemaDescriptor.version() != INITIAL_SCHEMA_VERSION) {
+                        fireEvent(
+                                TableEvent.ALTER,
+                                new TableEventParameters(causalityToken, 
tblId, tblName),
+                                new NodeStoppingException()
+                        );

Review comment:
       It is a fail event, this can be thrown just after an exception has 
happened.
   But if you are asking about an ordinal result when schema registered. It is 
a place where we may through earlier than the VersinedValue completed, because 
the corresponding object (a table) is already available and get the schema 
immediately.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to