Skip to content

Commit

Permalink
Undo //dev/release/coherence-v14.1.1.0/... changelist 113092 (14.1.1.…
Browse files Browse the repository at this point in the history
…0 cl 113118 --> ce/14.1.1.0)

[git-p4: depot-paths = "//dev/coherence-ce/release/coherence-ce-v14.1.1.0/": change = 113148]
  • Loading branch information
fryp committed Jan 3, 2025
1 parent cd96468 commit be02b00
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 471 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
package com.tangosol.persistence;

import com.oracle.coherence.persistence.FatalAccessException;
import com.oracle.coherence.persistence.PersistenceEnvironment;
import com.oracle.coherence.persistence.PersistenceException;
import com.oracle.coherence.persistence.PersistentStore;

Expand Down Expand Up @@ -43,7 +42,6 @@

import com.tangosol.net.partition.PartitionSet;

import com.tangosol.persistence.bdb.BerkeleyDBEnvironment;
import com.tangosol.persistence.bdb.BerkeleyDBManager;

import com.tangosol.util.Base;
Expand All @@ -55,16 +53,9 @@

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.Reader;
import java.io.Writer;

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

import static com.tangosol.util.ExternalizableHelper.toBinary;
Expand Down Expand Up @@ -1382,146 +1373,6 @@ public static String getMBeanName(String sService)
+ Registry.KEY_RESPONSIBILITY + PersistenceManagerMBean.PERSISTENCE_COORDINATOR;
}

public static void recordRecoveryStatus(PersistenceEnvironment env, String sSnapshot, boolean bRecoverySuccess, String sReason)
{
if (!(env instanceof BerkeleyDBEnvironment))
{
return;
}

File dirSnapshots = ((BerkeleyDBEnvironment) env).getPersistenceSnapshotDirectory();
Properties props = new Properties();
props.setProperty(RECOVERY_META_VERSION, "0");
props.setProperty(RECOVERY_META_STATUS_PROPERTY,
bRecoverySuccess
? RECOVERY_STATUS_SUCCESS
: String.format("%s: %s", RECOVERY_STATUS_FAILURE, sReason));
Writer writer = null;
try
{
File propsFile = dirSnapshots.toPath().resolve(sSnapshot).resolve(RECOVERY_META_FILENAME).toFile();
writer = new FileWriter(propsFile);
props.store(writer, RECOVERY_META_HEADER);
}
catch (IOException e)
{
CacheFactory.log(String.format("Cannot write properties file %s for snapshot '%s'", RECOVERY_META_FILENAME, sSnapshot), CacheFactory.LOG_DEBUG);
}
finally
{
if (writer != null)
{
try
{
writer.close();
}
catch (IOException ignored)
{
}
}
}
}

/**
* Return snapshot status.
*
* @param env the {@link PersistenceEnvironment} to query
* @param sName the snapshot name
*
* @return the snapshot status, or null if it is not possible
* to obtain the status.
*/
public static String getSnapshotStatus(PersistenceEnvironment env, String sName)
{
if (!(env instanceof BerkeleyDBEnvironment))
{
return null;
}

File dirSnapshot = new File(((BerkeleyDBEnvironment) env).getPersistenceSnapshotDirectory(), sName);
if (!dirSnapshot.isDirectory() || !dirSnapshot.canRead() || !dirSnapshot.canExecute())
{
return SNAPSHOT_STATUS_NOT_FOUND;
}

try
{
getSnapshotPersistenceTools(dirSnapshot).validate();
}
catch (RuntimeException e)
{
Throwable cause = e.getCause();
return String.format("%s: %s", RECOVERY_STATUS_FAILURE, cause == null ? e.getMessage() : cause.getMessage());
}
return SNAPSHOT_STATUS_COMPLETED;
}

/**
* Return recovery status for the given snapshot.
*
* @param env the {@link PersistenceEnvironment} to query
* @param sName the snapshot name
*
* @return the snapshot recovery status, or null if it is not
* possible to obtain the status.
*/
public static String getSnapshotRecoveryStatus(PersistenceEnvironment env, String sName)
{
if (!(env instanceof BerkeleyDBEnvironment))
{
return null;
}

File dirSnapshot = new File(((BerkeleyDBEnvironment) env).getPersistenceSnapshotDirectory(), sName);
if (!dirSnapshot.isDirectory() || !dirSnapshot.canRead() || !dirSnapshot.canExecute())
{
return SNAPSHOT_STATUS_NOT_FOUND;
}

try (Reader reader = new FileReader(new File(dirSnapshot, RECOVERY_META_FILENAME)))
{
Properties props = new Properties();
props.load(reader);
return props.getProperty(RECOVERY_META_STATUS_PROPERTY);
}
catch (FileNotFoundException e)
{
return SNAPSHOT_STATUS_NOT_FOUND;
}
catch (IOException | RuntimeException e)
{
return String.format("%s: %s", RECOVERY_STATUS_FAILURE, e.getMessage());
}
}

public static String[] getFailedSnapshots(PersistenceEnvironment env)
{
PersistenceEnvironment persistEnv = SafePersistenceWrappers.unwrap(env);
if (!(persistEnv instanceof BerkeleyDBEnvironment))
{
return null;
}

// respond with list of failed snapshots
File dirSnapshots = ((BerkeleyDBEnvironment) persistEnv).getPersistenceSnapshotDirectory();
String[] asSnapshots = persistEnv.listSnapshots();

List<String> asFailedSnapshots = new ArrayList<>();
for (String sName : asSnapshots)
{
File dirSnapshot = new File(dirSnapshots, sName);
try
{
getSnapshotPersistenceTools(dirSnapshot).validate();
}
catch (RuntimeException e)
{
asFailedSnapshots.add(sName);
}
}
return asFailedSnapshots.toArray(FAILED_SNAPSHOTS);
}

// ----- inner interface: Visitor -------------------------------------

/**
Expand Down Expand Up @@ -1726,49 +1577,4 @@ public static interface Visitor
* The marker Binary to represent a "false" binary value.
*/
private static final Binary BINARY_FALSE = new Binary(new byte[] { 0x0 });

/**
* Avoid allocating immutable array of strings.
*/
private static final String[] FAILED_SNAPSHOTS = new String[0];

/**
* The status to represent completed snapshot.
*/
static final String SNAPSHOT_STATUS_COMPLETED = "Completed";

/**
* The status to represent missing snapshot.
*/
static final String SNAPSHOT_STATUS_NOT_FOUND = "Not found";

/**
* Snapshot recovery status metadata filename.
*/
static final String RECOVERY_META_FILENAME = "recovery.properties";

/**
* Snapshot recovery status metadata property: implementation version.
*/
static final String RECOVERY_META_VERSION = "implementation.version";

/**
* Snapshot recovery status metadata property: header.
*/
static final String RECOVERY_META_HEADER = "Recovery status";

/**
* Snapshot recovery status metadata property: recovery status.
*/
static final String RECOVERY_META_STATUS_PROPERTY = "recovery";

/**
* Snapshot recovery status: success.
*/
static final String RECOVERY_STATUS_SUCCESS = "Succeeded";

/**
* Snapshot recovery status: failure.
*/
static final String RECOVERY_STATUS_FAILURE = "Failed";
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
*/
package com.tangosol.persistence;

import com.tangosol.net.management.Registry;

import com.tangosol.net.management.annotation.Description;
import com.tangosol.net.management.annotation.Notification;

Expand Down Expand Up @@ -74,14 +76,6 @@ public interface PersistenceManagerMBean
@Description("The list of snapshot identifiers that are available to recover from.")
public String[] getSnapshots();

/**
* Return a list of failed snapshots.
*
* @return a list of failed snapshots
*/
@Description("The list of failed snapshot identifiers.")
public String[] listFailedSnapshots();

// ----- snapshot operations --------------------------------------------

/**
Expand Down Expand Up @@ -114,22 +108,6 @@ public interface PersistenceManagerMBean
"Subscribe to JMX notifications to see the status of the operation.")
public void removeSnapshot(@Description("sName") String sName);

/**
* Return the status of the specific snapshot.
*
* @return the status of the specific snapshot
*/
@Description("The status of the specific snapshot.")
public String getSnapshotStatus(@Description("sName") String sName);

/**
* Return the recovery status of the specific snapshot.
*
* @return the recovery status of the specific snapshot
*/
@Description("The recovery status of the specific snapshot.")
public String getSnapshotRecoveryStatus(@Description("sName") String sName);

// ----- archive operations ---------------------------------------------

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,53 +78,6 @@ public Response getSnapshots()
filterAttributes, getLinksFilter()));
}

/**
* Return the status of the specific snapshot.
*
* @return the response object
*/
@GET
@Produces(MEDIA_TYPES)
@Path("snapshots/{" + SNAPSHOT_NAME + "}/status")
public Response getSnapshotStatus(@PathParam(SNAPSHOT_NAME) String sSnapshotName)
{
String[] asSignature = {String.class.getName()};
Object[] aoArguments = {sSnapshotName};

return response(getResponseFromMBeanOperation(getQuery(),
"status", "getSnapshotStatus", aoArguments, asSignature));
}

/**
* Return the recovery status of the specific snapshot.
*
* @return the response object
*/
@GET
@Produces(MEDIA_TYPES)
@Path("snapshots/{" + SNAPSHOT_NAME + "}/recover/status")
public Response getSnapshotRecoveryStatus(@PathParam(SNAPSHOT_NAME) String sSnapshotName)
{
String[] asSignature = {String.class.getName()};
Object[] aoArguments = {sSnapshotName};

return response(getResponseFromMBeanOperation(getQuery(),
"status", "getSnapshotRecoveryStatus", aoArguments, asSignature));
}

/**
* Return list of failed snapshots for a service.
*
* @return the response object
*/
@GET
@Produces(MEDIA_TYPES)
@Path("failedSnapshots")
public Response getFailedSnapshots()
{
return response(getResponseFromMBeanOperation( getQuery(),
"items", "listFailedSnapshots", null, null));
}
/**
* Return list of archived snapshots of a service.
*
Expand Down
Loading

0 comments on commit be02b00

Please sign in to comment.