Skip to content

Commit

Permalink
# IGNITE-226: WIP (14)
Browse files Browse the repository at this point in the history
  • Loading branch information
vozerov-gridgain committed Feb 13, 2015
1 parent 88bf144 commit 470ca3a
Show file tree
Hide file tree
Showing 14 changed files with 67 additions and 67 deletions.
Expand Up @@ -26,7 +26,7 @@
/** /**
* Data transfer object for {@link org.apache.ignite.IgniteFs}. * Data transfer object for {@link org.apache.ignite.IgniteFs}.
*/ */
public class VisorGgfs implements Serializable { public class VisorIgfs implements Serializable {
/** */ /** */
private static final long serialVersionUID = 0L; private static final long serialVersionUID = 0L;


Expand All @@ -37,7 +37,7 @@ public class VisorGgfs implements Serializable {
private final IgfsMode mode; private final IgfsMode mode;


/** GGFS metrics. */ /** GGFS metrics. */
private final VisorGgfsMetrics metrics; private final VisorIgfsMetrics metrics;


/** Whether GGFS has configured secondary file system. */ /** Whether GGFS has configured secondary file system. */
private final boolean secondaryFsConfigured; private final boolean secondaryFsConfigured;
Expand All @@ -50,10 +50,10 @@ public class VisorGgfs implements Serializable {
* @param metrics GGFS metrics. * @param metrics GGFS metrics.
* @param secondaryFsConfigured Whether GGFS has configured secondary file system. * @param secondaryFsConfigured Whether GGFS has configured secondary file system.
*/ */
public VisorGgfs( public VisorIgfs(
String name, String name,
IgfsMode mode, IgfsMode mode,
VisorGgfsMetrics metrics, VisorIgfsMetrics metrics,
boolean secondaryFsConfigured boolean secondaryFsConfigured
) { ) {
this.name = name; this.name = name;
Expand All @@ -67,13 +67,13 @@ public VisorGgfs(
* @return Data transfer object for given GGFS. * @return Data transfer object for given GGFS.
* @throws IgniteCheckedException * @throws IgniteCheckedException
*/ */
public static VisorGgfs from(IgniteFs ggfs) throws IgniteCheckedException { public static VisorIgfs from(IgniteFs ggfs) throws IgniteCheckedException {
assert ggfs != null; assert ggfs != null;


return new VisorGgfs( return new VisorIgfs(
ggfs.name(), ggfs.name(),
ggfs.configuration().getDefaultMode(), ggfs.configuration().getDefaultMode(),
VisorGgfsMetrics.from(ggfs.metrics()), VisorIgfsMetrics.from(ggfs.metrics()),
ggfs.configuration().getSecondaryFileSystem() != null ggfs.configuration().getSecondaryFileSystem() != null
); );
} }
Expand All @@ -95,7 +95,7 @@ public IgfsMode mode() {
/** /**
* @return GGFS metrics. * @return GGFS metrics.
*/ */
public VisorGgfsMetrics metrics() { public VisorIgfsMetrics metrics() {
return metrics; return metrics;
} }


Expand All @@ -108,6 +108,6 @@ public boolean secondaryFileSystemConfigured() {


/** {@inheritDoc} */ /** {@inheritDoc} */
@Override public String toString() { @Override public String toString() {
return S.toString(VisorGgfs.class, this); return S.toString(VisorIgfs.class, this);
} }
} }
Expand Up @@ -25,7 +25,7 @@
/** /**
* GGFS endpoint descriptor. * GGFS endpoint descriptor.
*/ */
public class VisorGgfsEndpoint implements Serializable{ public class VisorIgfsEndpoint implements Serializable{
/** */ /** */
private static final long serialVersionUID = 0L; private static final long serialVersionUID = 0L;


Expand All @@ -48,7 +48,7 @@ public class VisorGgfsEndpoint implements Serializable{
* @param hostName Host address / name. * @param hostName Host address / name.
* @param port Port number. * @param port Port number.
*/ */
public VisorGgfsEndpoint(@Nullable String ggfsName, String gridName, @Nullable String hostName, int port) { public VisorIgfsEndpoint(@Nullable String ggfsName, String gridName, @Nullable String hostName, int port) {
this.ggfsName = ggfsName; this.ggfsName = ggfsName;
this.gridName = gridName; this.gridName = gridName;
this.hostName = hostName; this.hostName = hostName;
Expand Down Expand Up @@ -101,6 +101,6 @@ else if (gridName == null)


/** {@inheritDoc} */ /** {@inheritDoc} */
@Override public String toString() { @Override public String toString() {
return S.toString(VisorGgfsEndpoint.class, this); return S.toString(VisorIgfsEndpoint.class, this);
} }
} }
Expand Up @@ -26,7 +26,7 @@
* Format GGFS instance. * Format GGFS instance.
*/ */
@GridInternal @GridInternal
public class VisorGgfsFormatTask extends VisorOneNodeTask<String, Void> { public class VisorIgfsFormatTask extends VisorOneNodeTask<String, Void> {
/** */ /** */
private static final long serialVersionUID = 0L; private static final long serialVersionUID = 0L;


Expand Down
Expand Up @@ -25,7 +25,7 @@
/** /**
* Data transfer object for {@link org.apache.ignite.ignitefs.IgfsMetrics}. * Data transfer object for {@link org.apache.ignite.ignitefs.IgfsMetrics}.
*/ */
public class VisorGgfsMetrics implements Serializable { public class VisorIgfsMetrics implements Serializable {
/** */ /** */
private static final long serialVersionUID = 0L; private static final long serialVersionUID = 0L;


Expand Down Expand Up @@ -75,10 +75,10 @@ public class VisorGgfsMetrics implements Serializable {
* @param m GGFS metrics. * @param m GGFS metrics.
* @return Data transfer object for given GGFS metrics. * @return Data transfer object for given GGFS metrics.
*/ */
public static VisorGgfsMetrics from(IgfsMetrics m) { public static VisorIgfsMetrics from(IgfsMetrics m) {
assert m != null; assert m != null;


VisorGgfsMetrics metrics = new VisorGgfsMetrics(); VisorIgfsMetrics metrics = new VisorIgfsMetrics();


metrics.totalSpaceSize(m.maxSpaceSize()); metrics.totalSpaceSize(m.maxSpaceSize());
metrics.usedSpaceSize(m.localSpaceSize()); metrics.usedSpaceSize(m.localSpaceSize());
Expand All @@ -104,7 +104,7 @@ public static VisorGgfsMetrics from(IgfsMetrics m) {
* @param m Metrics to add. * @param m Metrics to add.
* @return Self for method chaining. * @return Self for method chaining.
*/ */
public VisorGgfsMetrics add(VisorGgfsMetrics m) { public VisorIgfsMetrics add(VisorIgfsMetrics m) {
assert m != null; assert m != null;


totalSpaceSz += m.totalSpaceSz; totalSpaceSz += m.totalSpaceSz;
Expand All @@ -131,7 +131,7 @@ public VisorGgfsMetrics add(VisorGgfsMetrics m) {
* @param n Nodes count. * @param n Nodes count.
* @return Self for method chaining. * @return Self for method chaining.
*/ */
public VisorGgfsMetrics aggregate(int n) { public VisorIgfsMetrics aggregate(int n) {
if (n > 0) { if (n > 0) {
foldersCnt /= n; foldersCnt /= n;
filesCnt /= n; filesCnt /= n;
Expand Down Expand Up @@ -345,6 +345,6 @@ public void bytesWriteTime(long bytesWrtTm) {


/** {@inheritDoc} */ /** {@inheritDoc} */
@Override public String toString() { @Override public String toString() {
return S.toString(VisorGgfsMetrics.class, this); return S.toString(VisorIgfsMetrics.class, this);
} }
} }
Expand Up @@ -25,7 +25,7 @@
/** /**
* Various global constants for GGFS profiler. * Various global constants for GGFS profiler.
*/ */
public class VisorGgfsProfiler { public class VisorIgfsProfiler {
/** Default file block size to calculate uniformity. */ /** Default file block size to calculate uniformity. */
public static final int UNIFORMITY_DFLT_BLOCK_SIZE = 4096; public static final int UNIFORMITY_DFLT_BLOCK_SIZE = 4096;


Expand All @@ -38,15 +38,15 @@ public class VisorGgfsProfiler {
* @param entries Entries to sum. * @param entries Entries to sum.
* @return Single aggregated entry. * @return Single aggregated entry.
*/ */
public static VisorGgfsProfilerEntry aggregateGgfsProfilerEntries(List<VisorGgfsProfilerEntry> entries) { public static VisorIgfsProfilerEntry aggregateGgfsProfilerEntries(List<VisorIgfsProfilerEntry> entries) {
assert !F.isEmpty(entries); assert !F.isEmpty(entries);


if (entries.size() == 1) if (entries.size() == 1)
return entries.get(0); // No need to aggregate. return entries.get(0); // No need to aggregate.
else { else {
String path = entries.get(0).path(); String path = entries.get(0).path();


Collections.sort(entries, VisorGgfsProfilerEntry.ENTRY_TIMESTAMP_COMPARATOR); Collections.sort(entries, VisorIgfsProfilerEntry.ENTRY_TIMESTAMP_COMPARATOR);


long timestamp = 0; long timestamp = 0;
long size = 0; long size = 0;
Expand All @@ -57,9 +57,9 @@ public static VisorGgfsProfilerEntry aggregateGgfsProfilerEntries(List<VisorGgfs
long writeTime = 0; long writeTime = 0;
long userWriteTime = 0; long userWriteTime = 0;
IgfsMode mode = null; IgfsMode mode = null;
VisorGgfsProfilerUniformityCounters counters = new VisorGgfsProfilerUniformityCounters(); VisorIgfsProfilerUniformityCounters counters = new VisorIgfsProfilerUniformityCounters();


for (VisorGgfsProfilerEntry entry : entries) { for (VisorIgfsProfilerEntry entry : entries) {
// Take last timestamp. // Take last timestamp.
timestamp = entry.timestamp(); timestamp = entry.timestamp();


Expand All @@ -80,7 +80,7 @@ public static VisorGgfsProfilerEntry aggregateGgfsProfilerEntries(List<VisorGgfs
counters.aggregate(entry.counters()); counters.aggregate(entry.counters());
} }


return new VisorGgfsProfilerEntry(path, timestamp, mode, size, bytesRead, readTime, userReadTime, return new VisorIgfsProfilerEntry(path, timestamp, mode, size, bytesRead, readTime, userReadTime,
bytesWritten, writeTime, userWriteTime, counters); bytesWritten, writeTime, userWriteTime, counters);
} }
} }
Expand Down
Expand Up @@ -32,7 +32,7 @@
* Remove all GGFS profiler logs. * Remove all GGFS profiler logs.
*/ */
@GridInternal @GridInternal
public class VisorGgfsProfilerClearTask extends VisorOneNodeTask<String, IgniteBiTuple<Integer, Integer>> { public class VisorIgfsProfilerClearTask extends VisorOneNodeTask<String, IgniteBiTuple<Integer, Integer>> {
/** */ /** */
private static final long serialVersionUID = 0L; private static final long serialVersionUID = 0L;


Expand Down
Expand Up @@ -26,14 +26,14 @@
/** /**
* Visor GGFS profiler information about one file. * Visor GGFS profiler information about one file.
*/ */
public class VisorGgfsProfilerEntry implements Serializable { public class VisorIgfsProfilerEntry implements Serializable {
/** */ /** */
private static final long serialVersionUID = 0L; private static final long serialVersionUID = 0L;


/** Timestamp comparator. */ /** Timestamp comparator. */
public static final Comparator<VisorGgfsProfilerEntry> ENTRY_TIMESTAMP_COMPARATOR = public static final Comparator<VisorIgfsProfilerEntry> ENTRY_TIMESTAMP_COMPARATOR =
new Comparator<VisorGgfsProfilerEntry>() { new Comparator<VisorIgfsProfilerEntry>() {
@Override public int compare(VisorGgfsProfilerEntry a, VisorGgfsProfilerEntry b) { @Override public int compare(VisorIgfsProfilerEntry a, VisorIgfsProfilerEntry b) {
return Long.compare(a.timestamp, b.timestamp); return Long.compare(a.timestamp, b.timestamp);
} }
}; };
Expand Down Expand Up @@ -72,7 +72,7 @@ public class VisorGgfsProfilerEntry implements Serializable {
private double uniformity = -1; private double uniformity = -1;


/** Counters for uniformity calculation. */ /** Counters for uniformity calculation. */
private final VisorGgfsProfilerUniformityCounters counters; private final VisorIgfsProfilerUniformityCounters counters;


/** Read speed in bytes per second or {@code -1} if speed not available. */ /** Read speed in bytes per second or {@code -1} if speed not available. */
private final long readSpeed; private final long readSpeed;
Expand All @@ -81,7 +81,7 @@ public class VisorGgfsProfilerEntry implements Serializable {
private final long writeSpeed; private final long writeSpeed;


/** Create data transfer object with given parameters. */ /** Create data transfer object with given parameters. */
public VisorGgfsProfilerEntry( public VisorIgfsProfilerEntry(
String path, String path,
long timestamp, long timestamp,
IgfsMode mode, IgfsMode mode,
Expand All @@ -92,7 +92,7 @@ public VisorGgfsProfilerEntry(
long bytesWritten, long bytesWritten,
long writeTime, long writeTime,
long userWriteTime, long userWriteTime,
VisorGgfsProfilerUniformityCounters counters VisorIgfsProfilerUniformityCounters counters
) { ) {
assert counters != null; assert counters != null;


Expand Down Expand Up @@ -213,7 +213,7 @@ public double uniformity() {
/** /**
* @return Counters for uniformity calculation. * @return Counters for uniformity calculation.
*/ */
public VisorGgfsProfilerUniformityCounters counters() { public VisorIgfsProfilerUniformityCounters counters() {
return counters; return counters;
} }


Expand All @@ -233,6 +233,6 @@ public long writeSpeed() {


/** {@inheritDoc} */ /** {@inheritDoc} */
@Override public String toString() { @Override public String toString() {
return S.toString(VisorGgfsProfilerEntry.class, this); return S.toString(VisorIgfsProfilerEntry.class, this);
} }
} }
Expand Up @@ -36,7 +36,7 @@
* Task that parse hadoop profiler logs. * Task that parse hadoop profiler logs.
*/ */
@GridInternal @GridInternal
public class VisorGgfsProfilerTask extends VisorOneNodeTask<String, Collection<VisorGgfsProfilerEntry>> { public class VisorIgfsProfilerTask extends VisorOneNodeTask<String, Collection<VisorIgfsProfilerEntry>> {
/** */ /** */
private static final long serialVersionUID = 0L; private static final long serialVersionUID = 0L;


Expand Down Expand Up @@ -122,7 +122,7 @@ private VisorGgfsProfilerParsedLine(
/** /**
* Job that do actual profiler work. * Job that do actual profiler work.
*/ */
private static class VisorGgfsProfilerJob extends VisorJob<String, Collection<VisorGgfsProfilerEntry>> { private static class VisorGgfsProfilerJob extends VisorJob<String, Collection<VisorIgfsProfilerEntry>> {
/** */ /** */
private static final long serialVersionUID = 0L; private static final long serialVersionUID = 0L;


Expand Down Expand Up @@ -160,7 +160,7 @@ private VisorGgfsProfilerJob(String arg, boolean debug) {
} }


/** {@inheritDoc} */ /** {@inheritDoc} */
@Override protected Collection<VisorGgfsProfilerEntry> run(String arg) { @Override protected Collection<VisorIgfsProfilerEntry> run(String arg) {
try { try {
Path logsDir = resolveGgfsProfilerLogsDir(ignite.fileSystem(arg)); Path logsDir = resolveGgfsProfilerLogsDir(ignite.fileSystem(arg));


Expand Down Expand Up @@ -297,8 +297,8 @@ private VisorGgfsProfilerParsedLine parseLine(String s) {
/** /**
* Aggregate information from parsed lines grouped by {@code streamId}. * Aggregate information from parsed lines grouped by {@code streamId}.
*/ */
private VisorGgfsProfilerEntry aggregateParsedLines(List<VisorGgfsProfilerParsedLine> lines) { private VisorIgfsProfilerEntry aggregateParsedLines(List<VisorGgfsProfilerParsedLine> lines) {
VisorGgfsProfilerUniformityCounters counters = new VisorGgfsProfilerUniformityCounters(); VisorIgfsProfilerUniformityCounters counters = new VisorIgfsProfilerUniformityCounters();


Collections.sort(lines, PARSED_LINE_BY_TS_COMPARATOR); Collections.sort(lines, PARSED_LINE_BY_TS_COMPARATOR);


Expand Down Expand Up @@ -369,7 +369,7 @@ private VisorGgfsProfilerEntry aggregateParsedLines(List<VisorGgfsProfilerParsed


// Return only fully parsed data with path. // Return only fully parsed data with path.
return path.isEmpty() ? null : return path.isEmpty() ? null :
new VisorGgfsProfilerEntry( new VisorIgfsProfilerEntry(
path, path,
ts, ts,
mode, mode,
Expand All @@ -388,7 +388,7 @@ private VisorGgfsProfilerEntry aggregateParsedLines(List<VisorGgfsProfilerParsed
* @return Collection of parsed and aggregated entries. * @return Collection of parsed and aggregated entries.
* @throws IOException if failed to read log file. * @throws IOException if failed to read log file.
*/ */
private Collection<VisorGgfsProfilerEntry> parseFile(Path p) throws IOException { private Collection<VisorIgfsProfilerEntry> parseFile(Path p) throws IOException {
Collection<VisorGgfsProfilerParsedLine> parsedLines = new ArrayList<>(512); Collection<VisorGgfsProfilerParsedLine> parsedLines = new ArrayList<>(512);


try (BufferedReader br = Files.newBufferedReader(p, Charset.forName("UTF-8"))) { try (BufferedReader br = Files.newBufferedReader(p, Charset.forName("UTF-8"))) {
Expand Down Expand Up @@ -431,20 +431,20 @@ private Collection<VisorGgfsProfilerEntry> parseFile(Path p) throws IOException
} }


// Aggregate each group. // Aggregate each group.
Collection<VisorGgfsProfilerEntry> entries = new ArrayList<>(byStreamId.size()); Collection<VisorIgfsProfilerEntry> entries = new ArrayList<>(byStreamId.size());


for (List<VisorGgfsProfilerParsedLine> lines : byStreamId.values()) { for (List<VisorGgfsProfilerParsedLine> lines : byStreamId.values()) {
VisorGgfsProfilerEntry entry = aggregateParsedLines(lines); VisorIgfsProfilerEntry entry = aggregateParsedLines(lines);


if (entry != null) if (entry != null)
entries.add(entry); entries.add(entry);
} }


// Group by files. // Group by files.
Map<String, List<VisorGgfsProfilerEntry>> byPath = new HashMap<>(); Map<String, List<VisorIgfsProfilerEntry>> byPath = new HashMap<>();


for (VisorGgfsProfilerEntry entry: entries) { for (VisorIgfsProfilerEntry entry: entries) {
List<VisorGgfsProfilerEntry> grp = byPath.get(entry.path()); List<VisorIgfsProfilerEntry> grp = byPath.get(entry.path());


if (grp == null) { if (grp == null) {
grp = new ArrayList<>(); grp = new ArrayList<>();
Expand All @@ -456,10 +456,10 @@ private Collection<VisorGgfsProfilerEntry> parseFile(Path p) throws IOException
} }


// Aggregate by files. // Aggregate by files.
Collection<VisorGgfsProfilerEntry> res = new ArrayList<>(byPath.size()); Collection<VisorIgfsProfilerEntry> res = new ArrayList<>(byPath.size());


for (List<VisorGgfsProfilerEntry> lst : byPath.values()) for (List<VisorIgfsProfilerEntry> lst : byPath.values())
res.add(VisorGgfsProfiler.aggregateGgfsProfilerEntries(lst)); res.add(VisorIgfsProfiler.aggregateGgfsProfilerEntries(lst));


return res; return res;
} }
Expand All @@ -470,8 +470,8 @@ private Collection<VisorGgfsProfilerEntry> parseFile(Path p) throws IOException
* @param logDir Folder were log files located. * @param logDir Folder were log files located.
* @return List of line with aggregated information by files. * @return List of line with aggregated information by files.
*/ */
private Collection<VisorGgfsProfilerEntry> parse(Path logDir, String ggfsName) throws IOException { private Collection<VisorIgfsProfilerEntry> parse(Path logDir, String ggfsName) throws IOException {
Collection<VisorGgfsProfilerEntry> parsedFiles = new ArrayList<>(512); Collection<VisorIgfsProfilerEntry> parsedFiles = new ArrayList<>(512);


try (DirectoryStream<Path> dirStream = Files.newDirectoryStream(logDir)) { try (DirectoryStream<Path> dirStream = Files.newDirectoryStream(logDir)) {
PathMatcher matcher = FileSystems.getDefault().getPathMatcher("glob:ggfs-log-" + ggfsName + "-*.csv"); PathMatcher matcher = FileSystems.getDefault().getPathMatcher("glob:ggfs-log-" + ggfsName + "-*.csv");
Expand Down

0 comments on commit 470ca3a

Please sign in to comment.