Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sync with .net e73bbc2392f2e29ed3b6d9596c08aed0e08afef7..0111a936f92d… #84

Merged
merged 1 commit into from
Jan 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ public HttpRequestBase createRequest(ServerNode node, Reference<String> url) {
path += "&staleTimeout=" + TimeUtils.durationToTimeSpan(_options.getStaleTimeout());
}

if (_options.isIgnoreMaxStepsForScript()) {
path += "&ignoreMaxStepsForScript=" + _options.isIgnoreMaxStepsForScript();
}

HttpPatch request = new HttpPatch();
request.setEntity(new ContentProviderHttpEntity(outputStream -> {
try (JsonGenerator generator = createSafeJsonGenerator(outputStream)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
public class BackupConfiguration {

private BackupType backupType;
private BackupUploadMode backupUploadMode;
private SnapshotSettings snapshotSettings;
private BackupEncryptionSettings backupEncryptionSettings;

Expand All @@ -21,6 +22,14 @@ public void setBackupType(BackupType backupType) {
this.backupType = backupType;
}

public BackupUploadMode getBackupUploadMode() {
return backupUploadMode;
}

public void setBackupUploadMode(BackupUploadMode backupUploadMode) {
this.backupUploadMode = backupUploadMode;
}

public SnapshotSettings getSnapshotSettings() {
return snapshotSettings;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package net.ravendb.client.documents.operations.backups;

import net.ravendb.client.primitives.UseSharpEnum;

@UseSharpEnum
public enum BackupUploadMode {
DEFAULT,
DIRECT_UPLOAD
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package net.ravendb.client.documents.operations.backups;

import net.ravendb.client.primitives.UseSharpEnum;

@UseSharpEnum
public enum SnapshotBackupCompressionAlgorithm {
Zstd,
Deflate
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
package net.ravendb.client.documents.operations.backups;

public class SnapshotSettings {
private SnapshotBackupCompressionAlgorithm compressionAlgorithm;
private CompressionLevel compressionLevel;
private boolean excludeIndexes;

public SnapshotBackupCompressionAlgorithm getCompressionAlgorithm() {
return compressionAlgorithm;
}

public void setCompressionAlgorithm(SnapshotBackupCompressionAlgorithm compressionAlgorithm) {
this.compressionAlgorithm = compressionAlgorithm;
}

public CompressionLevel getCompressionLevel() {
return compressionLevel;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ private void writeParameterValue(Object value, ObjectMapper mapper) throws IOExc
for (Object o : ((Collection) value)) {
writeParameterValue(o, mapper);
}
write(((Collection<?>) value).size());
}
} else {
write(mapper.writeValueAsString(value));
Expand All @@ -139,7 +140,9 @@ public void write(Map<String, String> qp) throws IOException {
} else {
write(qp.size());
for (Map.Entry<String, String> kvp : qp.entrySet()) {
write("key");
write(kvp.getKey());
write("value");
write(kvp.getValue());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ public class QueryOperationOptions {

private boolean allowStale;

private boolean ignoreMaxStepsForScript;

private Duration staleTimeout;

private boolean retrieveDetails;
Expand All @@ -31,6 +33,21 @@ public void setAllowStale(boolean allowStale) {
this.allowStale = allowStale;
}

/**
* Ignore the maximum number of statements a script can execute as defined in the server configuration.
*/
public boolean isIgnoreMaxStepsForScript() {
return ignoreMaxStepsForScript;
}

/**
* Ignore the maximum number of statements a script can execute as defined in the server configuration.
* @param ignoreMaxStepsForScript steps
*/
public void setIgnoreMaxStepsForScript(boolean ignoreMaxStepsForScript) {
this.ignoreMaxStepsForScript = ignoreMaxStepsForScript;
}

/**
* If AllowStale is set to false and index is stale, then this is the maximum timeout to wait for index to become non-stale. If timeout is exceeded then exception is thrown.
* @return max time server can wait for stale results
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,13 @@ public interface IAdvancedDocumentSessionOperations {
*/
Map<String, List<DocumentsChanges>> whatChanged();

/**
* Returns all changes for the specified entity. Including name of the field/property that changed, its old and new value and change type.
* @param entity Entity
* @return list of changes
*/
List<DocumentsChanges> whatChangedFor(Object entity);

/**
* @return Returns all the tracked entities in this session.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1232,6 +1232,39 @@ public Map<String, List<DocumentsChanges>> whatChanged() {
return changes;
}

/**
* Returns all changes for the specified entity. Including name of the field/property that changed, its old and new value and change type.
* @param entity Entity
* @return list of changes
*/
public List<DocumentsChanges> whatChangedFor(Object entity) {
DocumentInfo documentInfo = documentsByEntity.get(entity);
if (documentInfo == null) {
return new ArrayList<>();
}

if (deletedEntities.contains(entity)) {
DocumentsChanges change = new DocumentsChanges();
change.setFieldNewValue("");
change.setFieldOldValue("");
change.setChange(DocumentsChanges.ChangeType.DOCUMENT_DELETED);

return Collections.singletonList(change);
}

updateMetadataModifications(documentInfo.getMetadataInstance(), documentInfo.getMetadata());
ObjectNode document = entityToJson.convertEntityToJson(documentInfo.getEntity(), documentInfo);

Map<String, List<DocumentsChanges>> changes = new HashMap<>();

if (!entityChanged(document, documentInfo, changes)) {
return new ArrayList<>();
}

return changes.get(documentInfo.getId());
}


public Map<String, DocumentsById.EntityInfo> getTrackedEntities() {
Map<String, DocumentsById.EntityInfo> tracked = documentsById.getTrackedEntities(this);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
package net.ravendb.client.documents.smuggler;

import java.util.ArrayList;
import java.util.List;

public class DatabaseSmugglerExportOptions extends DatabaseSmugglerOptions implements IDatabaseSmugglerExportOptions {
private ExportCompressionAlgorithm compressionAlgorithm;

public ExportCompressionAlgorithm getCompressionAlgorithm() {
return compressionAlgorithm;
}

public void setCompressionAlgorithm(ExportCompressionAlgorithm compressionAlgorithm) {
this.compressionAlgorithm = compressionAlgorithm;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ public class DatabaseSmugglerOptions implements IDatabaseSmugglerOptions {
private String encryptionKey;
private List<String> collections;

private boolean skipCorruptedData;

public DatabaseSmugglerOptions() {
this.operateOnTypes = DEFAULT_OPERATE_ON_TYPES.clone();
this.operateOnDatabaseRecordType = DEFAULT_OPERATE_ON_DATABASE_RECORD_TYPES.clone();
Expand Down Expand Up @@ -154,4 +156,18 @@ public List<String> getCollections() {
public void setCollections(List<String> collections) {
this.collections = collections;
}
/**
* In case the database is corrupted (for example, Compression Dictionaries are lost), it is possible to export all the remaining data.
*/
public boolean isSkipCorruptedData() {
return skipCorruptedData;
}

/**
* In case the database is corrupted (for example, Compression Dictionaries are lost), it is possible to export all the remaining data.
* @param skipCorruptedData skip corrupted data
*/
public void setSkipCorruptedData(boolean skipCorruptedData) {
this.skipCorruptedData = skipCorruptedData;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package net.ravendb.client.documents.smuggler;

import net.ravendb.client.primitives.UseSharpEnum;

@UseSharpEnum
public enum ExportCompressionAlgorithm {
ZSTD,
GZIP
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,7 @@ public interface IDatabaseSmugglerExportOptions extends IDatabaseSmugglerOptions

void setCollections(List<String> collections);

ExportCompressionAlgorithm getCompressionAlgorithm();

void setCompressionAlgorithm(ExportCompressionAlgorithm compressionAlgorithm);
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public class SubscriptionState {
private String nodeTag;
private Date lastBatchAckTime;
private Date lastClientConnectionTime;
private long raftCommandIndex;
private boolean disabled;

public String getQuery() {
Expand Down Expand Up @@ -88,6 +89,14 @@ public void setLastClientConnectionTime(Date lastClientConnectionTime) {
this.lastClientConnectionTime = lastClientConnectionTime;
}

public long getRaftCommandIndex() {
return raftCommandIndex;
}

public void setRaftCommandIndex(long raftCommandIndex) {
this.raftCommandIndex = raftCommandIndex;
}

public boolean isDisabled() {
return disabled;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ public CompletableFuture<Boolean> updateTopologyAsync(UpdateTopologyParameters p
throw new IllegalArgumentException("Parameters cannot be null");
}

if (_disableTopologyUpdates) {
return CompletableFuture.completedFuture(false);
}

if (_disposed) {
return CompletableFuture.completedFuture(false);
}
Expand Down
Loading
Loading