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

Expose the clock properties in CTFTrace #155

Merged
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
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2013, 2014 Ericsson
* Copyright (c) 2013, 2024 Ericsson
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
Expand Down Expand Up @@ -346,6 +346,6 @@ public void testParse() throws CTFException {
setUp();
assertEquals(new UUID(0xd18e637435a1cd42L, 0x8e70a9cffa712793L), CtfTestTraceUtils.getTrace(testTrace).getUUID());
assertEquals(1332166405241713920.0, CtfTestTraceUtils.getTrace(testTrace).getClock().getClockOffset(), 200.0);
assertEquals(8, CtfTestTraceUtils.getTrace(testTrace).getEnvironment().size());
assertEquals(10, CtfTestTraceUtils.getTrace(testTrace).getEnvironment().size());
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2011, 2023 Ericsson, Ecole Polytechnique de Montreal and others
* Copyright (c) 2011, 2024 Ericsson, Ecole Polytechnique de Montreal and others
*
* All rights reserved. This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0 which
Expand Down Expand Up @@ -29,9 +29,9 @@
import java.nio.file.StandardOpenOption;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
Expand Down Expand Up @@ -154,6 +154,18 @@ public String toString() {
private static final FileFilter METADATA_FILE_FILTER = new MetadataFileFilter();
private static final Comparator<File> METADATA_COMPARATOR = new MetadataComparator();

/**
* Clock offset property
*
* @since 6.1
*/
public static final String CLOCK_OFFSET = "clock_offset"; //$NON-NLS-1$

/**
* Clock scale property
*/
private static final String CLOCK_SCALE = "clock_scale"; //$NON-NLS-1$

private final DeclarationScope fScope = new DeclarationScope(null, MetadataStrings.TRACE);

private boolean fUUIDMismatchWarning = false;
Expand Down Expand Up @@ -777,7 +789,11 @@ public void addStream(ICTFStream stream) throws ParseException {
* (key, value)
*/
public Map<String, String> getEnvironment() {
return Collections.unmodifiableMap(fEnvironment);
Map<String, String> env = new LinkedHashMap<>();
env.putAll(fEnvironment);
env.put(CLOCK_OFFSET, String.valueOf(getOffset()));
env.put(CLOCK_SCALE, String.valueOf(getTimeScale()));
return env;
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2012, 2015 Ericsson
* Copyright (c) 2012, 2024 Ericsson
*
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License 2.0 which
Expand Down Expand Up @@ -245,7 +245,7 @@ public void testGetName() {
@Test
public void testGetTraceProperties() {
int result = fixture.getProperties().size();
assertEquals(10, result);
assertEquals(11, result);
assertEquals(String.valueOf(1332166405241713987L), fixture.getProperties().get("clock_offset"));
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2012, 2017 Ericsson, École Polytechnique de Montréal
* Copyright (c) 2012, 2024 Ericsson, École Polytechnique de Montréal
*
* All rights reserved. This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0 which
Expand Down Expand Up @@ -113,7 +113,9 @@ public class CtfTmfTrace extends TmfTrace
* Clock offset property
*
* @since 1.2
* @deprecated use {@link CTFTrace#CLOCK_OFFSET} instead
*/
@Deprecated
public static final String CLOCK_OFFSET = "clock_offset"; //$NON-NLS-1$

/**
Expand Down Expand Up @@ -584,7 +586,6 @@ public Map<String, String> getProperties() {
return properties;
}
properties.putAll(trace.getEnvironment());
properties.put(CLOCK_OFFSET, Long.toUnsignedString(trace.getOffset()));
properties.put(Messages.CtfTmfTrace_HostID, getHostId());
return properties;
}
Expand Down
Loading