Commit e139c2a3 authored by chiaming2000's avatar chiaming2000
Browse files

Improve simulator capacity reporting. The device capacity and remaining

information are calculated based on the persistent store path. 

A simulator instantiated on different path/partition will now report its
capacity information based on the store's path/partition.
parent 7ba0799a
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -108,7 +108,7 @@ public class GetLogHandler {

            switch (type) {
            case CAPACITIES:
                Capacity capacity = CapacityUtil.getCapacity();
                Capacity capacity = CapacityUtil.getCapacity(engine);
                getLog.setCapacity(capacity);
                break;
            case UTILIZATIONS:
+19 −0
Original line number Diff line number Diff line
@@ -905,4 +905,23 @@ public class SimulatorEngine implements MessageService {
        return this.deviceLocked;
    }
    
    /**
     * Get the absolute path of the persist store.
     * 
     * @return the absolute path of the persist store
     * 
     */
    public String getPersistStorePath() {

        String path = "/";

        try {
            path = this.store.getPersistStorePath();
        } catch (KVStoreException e) {
            logger.log(Level.WARNING, e.getMessage(), e);
        }

        return path;
    }

}
+16 −4
Original line number Diff line number Diff line
@@ -29,10 +29,13 @@ import com.seagate.kinetic.simulator.internal.KVStoreException;

/**
 *
 * DB Application (Raw) Interface.
 * Kinetic persist store (Raw) Interface.
 * 
 * @see StoreFactory 
 * 
 * @author James Hughes.
 * @author Chenchong Li
 * @author Chiaming Yang
 */
public interface Store<K, O, V> {

@@ -257,4 +260,13 @@ public interface Store<K, O, V> {
     *            if null then compaction ends at the last key
     */
    public void compactRange(K startKey, K endKey) throws KVStoreException;
    
    /**
     * Get the absolute path of the persist store.
     * 
     * @return the absolute path of the persist store
     * 
     * @throws KVStoreException if any internal error occurred.
     */
    public String getPersistStorePath() throws KVStoreException;
}
+6 −1
Original line number Diff line number Diff line
@@ -33,7 +33,7 @@ import com.seagate.kinetic.simulator.persist.PersistOption;
import com.seagate.kinetic.simulator.persist.Store;

/**
 * implement store
 * Implement Kinetic Store interface.
 *
 * XXX chiaming 12/24/2013: support PersistOption
 *
@@ -163,4 +163,9 @@ public class BdbStore implements Store<ByteString, ByteString, KVValue> {
        logger.warning("method is not implemented for bdb");
    }
    
    @Override
    public String getPersistStorePath() throws KVStoreException {
        return this.kvStore.getPersistStorePath();
    }

}
+14 −1
Original line number Diff line number Diff line
@@ -62,6 +62,8 @@ public final class KVStore {
	private final DatabaseConfig dbConfig = new DatabaseConfig();
	private String kineticDbName = null;
	
	private String persistFolder = null;

	static DatabaseEntry dbe(String s) {
		ByteString bs = ByteString.copyFromUtf8(s);
		DatabaseEntry dbe = new DatabaseEntry();
@@ -98,7 +100,7 @@ public final class KVStore {
					+ ", created=" + created);
		}

		String persistFolder = kineticHome
		persistFolder = kineticHome
				+ File.separator
				+ config.getProperty(SimulatorConfiguration.PERSIST_HOME, "bdb");

@@ -354,4 +356,15 @@ public final class KVStore {
		}
	}
	
    /**
     * Get persist store path.
     * 
     * @return persist store path.
     * @throws KVStoreException
     *             if any internal error occurred.
     */
    public String getPersistStorePath() throws KVStoreException {
        return this.persistFolder;
    }

}
Loading