Skip to content

Commit

Permalink
TEIID-3666 accounting for timing issue with loading
Browse files Browse the repository at this point in the history
Conflicts:
	jboss-integration/src/main/java/org/teiid/jboss/VDBService.java
  • Loading branch information
shawkins authored and johnathonlee committed Dec 2, 2015
1 parent 2e4a162 commit fbfb0c9
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 24 deletions.
2 changes: 2 additions & 0 deletions build/kits/jboss-as7/docs/teiid/teiid-releasenotes.html
Expand Up @@ -350,6 +350,8 @@ <h4>from 8.7.5</h4>
</li>
<li>[<a href='https://issues.jboss.org/browse/TEIID-3707'>TEIID-3707</a>] - Wrong Data returned when a procedure is executed in the SELECT clause
</li>
<li>[<a href='https://issues.jboss.org/browse/TEIID-3666'>TEIID-3666</a>] - VDB can deploy before datasource is bound
</li>
</ul>

<h4>from 8.7.4</h4>
Expand Down
45 changes: 23 additions & 22 deletions jboss-integration/src/main/java/org/teiid/jboss/VDBService.java
Expand Up @@ -400,8 +400,10 @@ public void run() {
}
}
}

synchronized (vdb) {
VDBStatusChecker marked = model.removeAttachment(VDBStatusChecker.class);

if (ex == null) {
if (!cached) {
// cache the schema to disk
Expand All @@ -421,34 +423,33 @@ public void run() {
if (ex instanceof RuntimeException) {
metadataLoaded(vdb, model, vdbMetadataStore, loadCount, factory, false, VDBService.this.shutdownListener.isBootInProgress());
} else {
//defer the load to the status checker if/when a source is available/redeployed
model.addAttchment(Runnable.class, this);
if (marked != null) {
getExecutor().execute(this);
} else {
//defer the load to the status checker if/when a source is available/redeployed
model.addAttchment(Runnable.class, this);
}
}
}
}
}
};

Executor executor = getExecutor();
if (executor == null) {
job.run();
}
else {
//wrap the runnable to trap exceptions that may be caused by an asynch deployment issue
executor.execute(new Runnable() {
@Override
public void run() {
try {
job.run();
} catch (IllegalStateException e) {
if (vdb.getStatus() != Status.FAILED && vdb.getStatus() != Status.REMOVED) {
throw e;
}
LogManager.logDetail(LogConstants.CTX_RUNTIME, e, "Could not load metadata for a removed or failed deployment.");
}
}
});
}
//wrap the runnable to trap exceptions that may be caused by an asynch deployment issue
executor.execute(new Runnable() {
@Override
public void run() {
try {
job.run();
} catch (IllegalStateException e) {
if (vdb.getStatus() != Status.FAILED && vdb.getStatus() != Status.REMOVED) {
throw e;
}
LogManager.logDetail(LogConstants.CTX_RUNTIME, e, "Could not load metadata for a removed or failed deployment."); //$NON-NLS-1$
}
}
});
}

private void cacheMetadataStore(final ModelMetaData model, MetadataFactory schema) {
Expand Down
Expand Up @@ -168,12 +168,12 @@ private void resourceAdded(String resourceName, List<Runnable> runnables,
boolean usesResourse = false;
for (ModelMetaData model:vdb.getModelMetaDatas().values()) {
if (!model.hasRuntimeMessages()) {
return;
continue;
}

String sourceName = getSourceName(resourceName, model);
if (sourceName == null) {
return;
continue;
}

usesResourse = true;
Expand Down Expand Up @@ -202,6 +202,7 @@ private void updateVDB(List<Runnable> runnables, VDBMetaData vdb) {
private void checkStatus(List<Runnable> runnables, VDBMetaData vdb,
ModelMetaData model, ConnectorManager cm) {
//get the pending metadata load
model.removeAttachment(VDBStatusChecker.class);
Runnable r = model.removeAttachment(Runnable.class);
if (r != null) {
runnables.add(r);
Expand All @@ -213,6 +214,10 @@ private void checkStatus(List<Runnable> runnables, VDBMetaData vdb,
LogManager.logInfo(LogConstants.CTX_RUNTIME, status);
} else if (vdb.getStatus() != Status.LOADING){
model.clearRuntimeMessages();
} else {
//mark the model to indicate that it should be reloaded if it
//is currently failing a load
model.addAttchment(VDBStatusChecker.class, this);
}
}
}
Expand Down

0 comments on commit fbfb0c9

Please sign in to comment.