Skip to content

Commit

Permalink
fixing #136
Browse files Browse the repository at this point in the history
  • Loading branch information
dsukhoroslov committed Jan 4, 2018
1 parent 145cd4f commit 1d4a77c
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 42 deletions.
4 changes: 2 additions & 2 deletions bagri-samples/bagri-samples-csharp/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.bagridb</groupId>
<artifactId>bagri-samples</artifactId>
<version>1.1.2</version>
<version>1.2.0-RC1</version>
<relativePath>..</relativePath>
</parent>

Expand Down Expand Up @@ -42,7 +42,7 @@
<argument>/reference:IKVM.OpenJDK.XML.API.7.2.4630.5/lib/IKVM.OpenJDK.XML.API.dll</argument>
<argument>/reference:IKVM.OpenJDK.XML.XPath.7.2.4630.5/lib/IKVM.OpenJDK.XML.XPath.dll</argument-->
<argument>/lib:${ikvm.home}\bin</argument>
<argument>/reference:Bagri.XQJ.Client.1.1.2.dll</argument>
<argument>/reference:Bagri.XQJ.Client.${project.version}.dll</argument>
<argument>/reference:IKVM.OpenJDK.Core.dll</argument>
<argument>/reference:IKVM.OpenJDK.XML.API.dll</argument>
<argument>/reference:IKVM.OpenJDK.XML.XPath.dll</argument>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -826,9 +826,20 @@ public Document processDocument(Map.Entry<DocumentKey, Document> old, long txId,
content = mergeContent(docKey, content, dataFormat);
}
}

// remove stats for old version
for (int clnId: updated.getCollections()) {
for (Collection cln: repo.getSchema().getCollections()) {
if (clnId == cln.getId()) {
updateStats(cln.getName(), false, updated.getElements(), updated.getFragments().length);
break;
}
}
}
updateStats(null, false, updated.getElements(), updated.getFragments().length);
}
// why before insert trigger not invoked?

int length = pRes.getContentLength();
String root = pRes.getContentRoot();
if (rSize > 0) {
Expand All @@ -844,17 +855,16 @@ public Document processDocument(Map.Entry<DocumentKey, Document> old, long txId,
Collection cln = repo.getSchema().getCollection(clName);
if (cln != null) {
newDoc.addCollection(cln.getId());
updateStats(clName, true, rSize, 0);
//updateStats(clName, true, paths.size(), doc.getFragments().length);
updateStats(clName, true, newDoc.getElements(), newDoc.getFragments().length);
}
}
} else {
String clName = checkDefaultDocumentCollection(newDoc);
if (clName != null) {
updateStats(clName, true, rSize, 0);
updateStats(clName, true, newDoc.getElements(), newDoc.getFragments().length);
}
}
updateStats(null, true, rSize, 0);
updateStats(null, true, newDoc.getElements(), newDoc.getFragments().length);

Scope scope;
if (old.getValue() == null) {
Expand Down Expand Up @@ -1084,7 +1094,6 @@ public DocumentAccessor removeDocument(String uri, Properties props) throws Bagr
}

DocumentKey docKey = factory.newDocumentKey(doc.getDocumentKey());

return removeDocumentInternal(docKey, doc, props);
}

Expand Down Expand Up @@ -1324,9 +1333,7 @@ public int updateDocumentCollections(boolean add, Map.Entry<DocumentKey, Documen
int updCount = 0;
Document doc = entry.getValue();
if (doc != null) {
// TODO: cache size in the doc itself? yes, done
// but must fix stats to account this size
int size = 0;
int size = doc.getElements();
for (Collection cln: repo.getSchema().getCollections()) {
for (String collection: collections) {
if (collection.equals(cln.getName())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import static com.bagri.support.util.CollectionUtils.copyIterator;
import static com.bagri.support.util.PropUtils.propsFromString;

import java.awt.Component;
import java.io.IOException;
import java.nio.file.DirectoryStream;
import java.nio.file.Files;
Expand All @@ -20,7 +19,6 @@

import javax.management.openmbean.CompositeData;
import javax.management.openmbean.TabularData;
import javax.swing.JLabel;

import org.springframework.jmx.export.annotation.ManagedAttribute;
import org.springframework.jmx.export.annotation.ManagedOperation;
Expand All @@ -30,7 +28,6 @@

import com.bagri.core.api.BagriException;
import com.bagri.core.api.DocumentAccessor;
import com.bagri.core.model.Document;
import com.bagri.core.system.Collection;
import com.bagri.core.system.Schema;
import com.bagri.server.hazelcast.task.doc.DocumentStructureProvider;
Expand All @@ -41,7 +38,6 @@
import com.bagri.support.stats.StatsAggregator;
import com.bagri.support.util.FileUtils;
import com.bagri.support.util.JMXUtils;
import com.bagri.support.util.PropUtils;
import com.hazelcast.core.Member;
import com.hazelcast.core.Partition;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

import com.bagri.tools.vvm.model.Collection;
import com.bagri.tools.vvm.model.Document;
import com.bagri.tools.vvm.util.FileUtil;

public class DocumentServiceProvider implements DocumentManagementService {

Expand Down Expand Up @@ -50,18 +49,7 @@ public List<Collection> getCollections() throws ServiceException {
if (stats != null) {
stsData = stats.get(index);
}
Collection cln;
if (stsData != null) {
cln = new Collection((String) clnData.get("name"), (String) clnData.get("description"), (String) clnData.get("created at"),
(String) clnData.get("created by"), (Integer) clnData.get("id"), (Integer) clnData.get("version"), (String) clnData.get("document type"),
(Boolean) clnData.get("enabled"), (Integer) stsData.get("Number of documents"), (Integer) stsData.get("Number of elements"), (Integer)
stsData.get("Number of fragments"), (Long) stsData.get("Consumed size"), ((Double) stsData.get("Avg size (bytes)")).intValue(),
((Double) stsData.get("Avg size (elmts)")).intValue());
} else {
cln = new Collection((String) clnData.get("name"), (String) clnData.get("description"), (String) clnData.get("created at"),
(String) clnData.get("created by"), (Integer) clnData.get("id"), (Integer) clnData.get("version"), (String) clnData.get("document type"),
(Boolean) clnData.get("enabled"), 0, 0, 0, 0, 0, 0);
}
Collection cln = readCollection(clnData, stsData);
result.add(cln);
}
return result;
Expand All @@ -74,7 +62,6 @@ public List<Collection> getCollections() throws ServiceException {
@Override
public void addCollection(Collection collection) throws ServiceException {
// TODO Auto-generated method stub

}

@Override
Expand Down Expand Up @@ -103,19 +90,7 @@ public Collection getCollection(String collection) throws ServiceException {
if (stats != null) {
stsData = stats.get(index);
}
Collection cln;
if (stsData != null) {
cln = new Collection((String) clnData.get("name"), (String) clnData.get("description"), (String) clnData.get("created at"),
(String) clnData.get("created by"), (Integer) clnData.get("id"), (Integer) clnData.get("version"), (String) clnData.get("document type"),
(Boolean) clnData.get("enabled"), (Integer) stsData.get("Number of documents"), (Integer) stsData.get("Number of elements"), (Integer)
stsData.get("Number of fragments"), (Long) stsData.get("Consumed size"), ((Double) stsData.get("Avg size (bytes)")).intValue(),
((Double) stsData.get("Avg size (elmts)")).intValue());
} else {
cln = new Collection((String) clnData.get("name"), (String) clnData.get("description"), (String) clnData.get("created at"),
(String) clnData.get("created by"), (Integer) clnData.get("id"), (Integer) clnData.get("version"), (String) clnData.get("document type"),
(Boolean) clnData.get("enabled"), 0, 0, 0, 0, 0, 0);
}
return cln;
return readCollection(clnData, stsData);
}
}
}
Expand All @@ -125,6 +100,20 @@ public Collection getCollection(String collection) throws ServiceException {
throw new ServiceException(ex);
}
}

private Collection readCollection(CompositeData clnData, CompositeData stsData) {
if (stsData != null) {
return new Collection((String) clnData.get("name"), (String) clnData.get("description"), (String) clnData.get("created at"),
(String) clnData.get("created by"), (Integer) clnData.get("id"), (Integer) clnData.get("version"), (String) clnData.get("document type"),
(Boolean) clnData.get("enabled"), (Integer) stsData.get("Number of documents"), (Integer) stsData.get("Number of elements"), (Integer)
stsData.get("Number of fragments"), (Long) stsData.get("Consumed size"), ((Double) stsData.get("Avg size (bytes)")).intValue(),
((Double) stsData.get("Avg size (elmts)")).intValue());
} else {
return new Collection((String) clnData.get("name"), (String) clnData.get("description"), (String) clnData.get("created at"),
(String) clnData.get("created by"), (Integer) clnData.get("id"), (Integer) clnData.get("version"), (String) clnData.get("document type"),
(Boolean) clnData.get("enabled"), 0, 0, 0, 0, 0, 0);
}
}

@Override
public void deleteCollection(String collection) throws ServiceException {
Expand Down

0 comments on commit 1d4a77c

Please sign in to comment.