Skip to content

Commit

Permalink
fix issues in conjunction with #1186: non-streaming checkin/deserializer
Browse files Browse the repository at this point in the history
This may not be of much use because the non-streaming IFC deserializers
are deprecated, and the non-streaming geometry generator lags behind.
  • Loading branch information
hlg committed Oct 28, 2024
1 parent d58b682 commit 28c557d
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 51 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ public int compare(Density o1, Density o2) {

OidCounters oidCounters = new OidCounters();
for (EClass eClass : eClasses) {
long oid = startOids.get(eClass);
long oid = startOids.get(eClass.getEPackage().getName() + "." + eClass.getName());
if (!DatabaseSession.perRecordVersioning(eClass)) {
oidCounters.put(eClass, oid);
}
Expand Down
21 changes: 19 additions & 2 deletions BimServer/src/org/bimserver/longaction/LongCheckinAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
import org.bimserver.database.actions.CheckinDatabaseAction;
import org.bimserver.database.berkeley.BimserverConcurrentModificationDatabaseException;
import org.bimserver.interfaces.objects.SProgressTopicType;
import org.bimserver.models.store.ActionState;
import org.bimserver.models.store.Project;
import org.bimserver.models.store.*;
import org.bimserver.plugins.deserializers.DeserializeException;
import org.bimserver.shared.exceptions.ServiceException;
import org.bimserver.shared.exceptions.UserException;
import org.bimserver.webservices.authorization.Authorization;
Expand All @@ -40,6 +40,8 @@ public class LongCheckinAction extends LongAction {
private static final Logger LOGGER = LoggerFactory.getLogger(LongCheckinAction.class);
private CheckinDatabaseAction checkinDatabaseAction;
private String fileName;
private long roid;
private DeserializeException deserializerException;

public LongCheckinAction(Long topicId, BimServer bimServer, String username, String userUsername, Authorization authorization, CheckinDatabaseAction checkinDatabaseAction) {
super(bimServer, username, userUsername, authorization);
Expand Down Expand Up @@ -92,8 +94,12 @@ public void retry(int count) {
this.count = count;
}
});
this.roid = checkinDatabaseAction.getRevision().getOid();
} catch (Exception e) {
if (e instanceof UserException) {
if (e.getCause() instanceof DeserializeException) {
this.deserializerException = (DeserializeException) e.getCause();
}
} else if (e instanceof BimserverConcurrentModificationDatabaseException) {
// Ignore
} else {
Expand Down Expand Up @@ -122,4 +128,15 @@ protected void done() {
public String getDescription() {
return getClass().getSimpleName();
}

@Override
public synchronized LongActionState getState() {
LongCheckinActionState ds = StoreFactory.eINSTANCE.createLongCheckinActionState();
ds.setRoid(roid);
if (deserializerException != null) {
ds.setDeserializeErrorCode(deserializerException.getDeserializerErrorCode().getCode());
}
super.fillState(ds);
return ds;
}
}
76 changes: 38 additions & 38 deletions BimServer/src/org/bimserver/notifications/ProgressTopic.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,28 +27,28 @@
import org.bimserver.shared.exceptions.UserException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class ProgressTopic extends Topic {

private static final Logger LOGGER = LoggerFactory.getLogger(ProgressTopic.class);
public class ProgressTopic extends Topic {

private static final Logger LOGGER = LoggerFactory.getLogger(ProgressTopic.class);
private static final long RATE_LIMIT_NANO_SECONDS = 200000000; // 200ms
private SProgressTopicType type;
private String description;
private ProgressTopicKey key;
private SProgressTopicType type;
private String description;
private ProgressTopicKey key;
private volatile LongActionState lastProgress;
private long lastSent = -1;

private long lastSent = -1;

public ProgressTopic(NotificationsManager notificationsManager, ProgressTopicKey key, SProgressTopicType type, String description) {
super(notificationsManager);
this.key = key;
this.type = type;
super(notificationsManager);
this.key = key;
this.type = type;
this.description = description;
}

public ProgressTopicKey getKey() {
return key;
}

}

public ProgressTopicKey getKey() {
return key;
}

protected synchronized void updateProgress(final LongActionState state) {
try {
// Actually we should be keeping track of when we last sent a message to A SPECIFIC ENDPOINT, this way, new endpoints won't receive the message rights away
Expand All @@ -58,7 +58,7 @@ protected synchronized void updateProgress(final LongActionState state) {
sendMessage |= state.getState() == ActionState.FINISHED;
sendMessage |= state.getState() == ActionState.AS_ERROR;
sendMessage |= lastProgress != null && lastProgress.getStage() != state.getStage();
sendMessage |= lastProgress != null && ((lastProgress.getTitle() == null && state.getTitle() != null) || (lastProgress.getTitle() != null && state.getTitle() == null) || !lastProgress.getTitle().equals(state.getTitle()));
sendMessage |= lastProgress != null && ((lastProgress.getTitle() == null && state.getTitle() != null) || (lastProgress.getTitle() != null && !lastProgress.getTitle().equals(state.getTitle())));

if (sendMessage) {
try {
Expand All @@ -67,11 +67,11 @@ protected synchronized void updateProgress(final LongActionState state) {
@Override
public void map(EndPoint endPoint) throws UserException, ServerException, BimserverDatabaseException {
try {
endPoint.getNotificationInterface().progress(key.getId(), new SConverter().convertToSObject(state));
} catch (Exception e) {
LOGGER.error("", e);
endPoint.getNotificationInterface().progress(key.getId(), new SConverter().convertToSObject(state));
} catch (Exception e) {
LOGGER.error("", e);
}
}
}
});
} catch (Exception e) {
LOGGER.error("", e);
Expand All @@ -83,22 +83,22 @@ public void map(EndPoint endPoint) throws UserException, ServerException, Bimser
}
} catch (Exception e) {
LOGGER.error("", e);
}
}

public LongActionState getLastProgress() {
return lastProgress;
}

public SProgressTopicType getType() {
return type;
}

public String getDescription() {
return description;
}

public void close() {
}
}

public LongActionState getLastProgress() {
return lastProgress;
}

public SProgressTopicType getType() {
return type;
}

public String getDescription() {
return description;
}

public void close() {
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,16 @@ public int read(byte[] b, int off, int len) throws IOException {
@Override
public void close() throws IOException {
// LOGGER.error("Closing " + id, new Exception());

// Read the rest of the inputstream
try {
IOUtils.copy(inputStream, new NullOutputStream());
} catch (EOFException e) {
// Skip, not a problem
if(latch.getCount()>0){ // Accept multiple calls to close() and ignore subsequent
// Read the rest of the inputstream
try {
IOUtils.copy(inputStream, new NullOutputStream());
} catch (EOFException e) {
// Skip, not a problem
}
latch.countDown();
inputStream.close();
}
latch.countDown();
inputStream.close();
}

public void await() throws InterruptedException {
Expand Down
4 changes: 2 additions & 2 deletions BimServer/src/org/bimserver/webservices/impl/ServiceImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -1167,8 +1167,8 @@ public SLongCheckinActionState checkinInitiatedSync(Long topicId, final Long poi

@Override
public Long checkinInitiatedAsync(Long topicId, final Long poid, final String comment, Long deserializerOid, Long fileSize, String fileName, DataHandler dataHandler, Boolean merge) throws ServerException, UserException {
SLongActionState checkinInitiatedInternal = checkinInitiatedInternal(topicId, poid, comment, deserializerOid, fileSize, fileName, dataHandler, merge, false, -1);
return checkinInitiatedInternal.getTopicId();
checkinInitiatedInternal(topicId, poid, comment, deserializerOid, fileSize, fileName, dataHandler, merge, false, -1);
return topicId;
}

private SLongCheckinActionState checkinInternal(Long topicId, final Long poid, final String comment, Long deserializerOid, Long fileSize, String fileName, InputStream originalInputStream, Boolean merge, Boolean sync,
Expand Down

0 comments on commit 28c557d

Please sign in to comment.