Skip to content

Commit

Permalink
Telegraf configure view. (+1 squashed commit)
Browse files Browse the repository at this point in the history
Squashed commits:
[6a806b2] [WIP] Telegraf configure view.
  • Loading branch information
gunlee01 committed Jan 12, 2019
1 parent 9fb778b commit 8c60895
Show file tree
Hide file tree
Showing 41 changed files with 3,458 additions and 85 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,4 @@ scouter.common/.settings/org.eclipse.core.resources.prefs
scouter.agent.host/.settings/org.eclipse.core.resources.prefs
scouter.agent.batch/.settings/org.eclipse.core.resources.prefs
/scouter.webapp/conf/scouterConfSample3.conf
scouter.server.jar
3 changes: 2 additions & 1 deletion scouter.client/.classpath
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src/"/>
<classpathentry kind="src" path="src"/>
<classpathentry exported="true" kind="lib" path="lib/scouter.common.jar" sourcepath="/scouter.common"/>
<classpathentry exported="true" kind="lib" path="lib/hibernate-core-3.3.2.GA.jar"/>
<classpathentry exported="true" kind="lib" path="lib/opencsv-2.4.jar"/>
<classpathentry exported="true" kind="lib" path="lib/opal-1.0.3.jar"/>
<classpathentry kind="lib" path="lib/scouter.server.jar"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
9 changes: 8 additions & 1 deletion scouter.client/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,18 @@ Require-Bundle: org.eclipse.ui,
org.eclipse.zest.core,
org.eclipse.zest.layouts,
org.apache.httpcomponents.httpclient,
org.apache.httpcomponents.httpcore
org.apache.httpcomponents.httpcore,
org.eclipse.core.databinding,
org.eclipse.core.databinding.beans,
org.eclipse.core.databinding.observable,
org.eclipse.core.databinding.property,
org.eclipse.jface.databinding,
com.ibm.icu
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-ActivationPolicy: lazy
Bundle-ClassPath: .,
lib/scouter.common.jar,
lib/scouter.server.jar,
lib/hibernate-core-3.3.2.GA.jar,
lib/opencsv-2.4.jar,
lib/opal-1.0.3.jar
8 changes: 8 additions & 0 deletions scouter.client/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1031,6 +1031,14 @@
name="Batch Active List"
restorable="false">
</view>
<view
allowMultiple="true"
class="scouter.client.configuration.views.TelegrafConfigView"
id="scouter.client.configuration.views.TelegrefConfigView"
icon="icons/config.png"
name="Telegraf Config"
restorable="false">
</view>
</extension>
<extension point="org.eclipse.ui.commands">
<category id="scouter.client.category" name="Scouter"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* Copyright 2015 the original author or authors.
* @https://github.com/scouter-project/scouter
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package scouter.client.configuration.actions;

import org.eclipse.jface.action.Action;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PartInitException;
import scouter.client.Images;
import scouter.client.configuration.views.TelegrafConfigView;
import scouter.client.util.ImageUtil;

public class OpenTelegrafConfigureAction extends Action {
public final static String ID = OpenTelegrafConfigureAction.class.getName();

private final IWorkbenchWindow win;
private int serverId;
public OpenTelegrafConfigureAction(IWorkbenchWindow win, String label, int serverId) {
this.win = win;
this.serverId = serverId;
setText(label);
setImageDescriptor(ImageUtil.getImageDescriptor(Images.config));
}

public void run() {
if (win != null) {
try {
TelegrafConfigView v = (TelegrafConfigView) win.getActivePage().showView(TelegrafConfigView.ID, "" + serverId, IWorkbenchPage.VIEW_ACTIVATE);
if(v != null)
v.setInput(serverId);
} catch (PartInitException e) {
MessageDialog.openError(win.getShell(), "Error", "Error opening view:" + e.getMessage());
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* Copyright 2015 the original author or authors.
* @https://github.com/scouter-project/scouter
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

package scouter.client.configuration.model;

import java.util.List;
import java.util.stream.Collectors;

/**
* @author Gun Lee (gunlee01@gmail.com) on 06/01/2019
*/
public class SingleString {
public String value;
public SingleString() {
}

public SingleString(String value) {
this.value = value;
}

public static List<SingleString> of(List<String> list) {
return list.stream().map(v -> new SingleString(v)).collect(Collectors.toList());
}

public static List<String> toOriginal(List<SingleString> singleStrings) {
return singleStrings.stream().map(s -> s.value).collect(Collectors.toList());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/*
* Copyright 2015 the original author or authors.
* @https://github.com/scouter-project/scouter
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

package scouter.client.configuration.model;

import scouter.server.support.telegraf.TgmConfig;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

import static java.util.stream.Collectors.groupingBy;
import static java.util.stream.Collectors.toList;

/**
* @author Gun Lee (gunlee01@gmail.com) on 06/01/2019
*/
public class TagFilterMapping {
public String tag;
public String mappingValue;

public TagFilterMapping() {
}

public TagFilterMapping(String tag, String mappingValue) {
this.tag = tag;
this.mappingValue = mappingValue;
}

public static List<TagFilterMapping> of(List<TgmConfig.TagFilter> tfList) {
List<TagFilterMapping> list = new ArrayList<>();
for (TgmConfig.TagFilter filter : tfList) {
for (String match : filter.match) {
TagFilterMapping mapping = new TagFilterMapping(filter.tag, match);
list.add(mapping);
}
}
return list;
}

public static List<TgmConfig.TagFilter> toOriginal(List<TagFilterMapping> mappings) {
return mappings.stream()
.collect(groupingBy(m -> m.tag))
.entrySet().stream()
.map(
e -> new TgmConfig.TagFilter(
e.getKey(),
e.getValue().stream()
.map(m -> m.mappingValue)
.collect(Collectors.toList())
.toArray(new String[0])
)
)
.collect(toList());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/*
* Copyright 2015 the original author or authors.
* @https://github.com/scouter-project/scouter
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

package scouter.client.configuration.model;

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

/**
* @author Gun Lee (gunlee01@gmail.com) on 03/01/2019
*/
public class TreeModel {

public TreeModel parent;
public List<TreeModel> child = new ArrayList<>();

public String displayName;
public Object element;

public TreeModel(TreeModel parent, String displayName) {
this(parent, displayName, new Object());
}

public TreeModel(TreeModel parent, String displayName, Object element) {
this.parent = parent;
this.displayName = displayName;
if (parent != null) {
parent.addChild(this);
}
this.element = element;
}

public String getDisplayName() {
return displayName;
}

public void setDisplayName(String displayName) {
this.displayName = displayName;
}

public Object getElement() {
return element;
}

public void setElement(Object element) {
this.element = element;
}

private void addChild(TreeModel model) {
child.add(model);
}

public void removeMe() {
if (parent == null) {
throw new IllegalStateException("Root Node!");
}
parent.child.remove(this);
}
}
Loading

0 comments on commit 8c60895

Please sign in to comment.