Skip to content

Commit

Permalink
Merge branch 'master' into feature-separate-remote-poller
Browse files Browse the repository at this point in the history
  • Loading branch information
soleger committed Jun 4, 2014
2 parents 0357362 + 24054f3 commit c9948fe
Show file tree
Hide file tree
Showing 32 changed files with 316 additions and 105 deletions.
177 changes: 155 additions & 22 deletions bin/functions.pl
@@ -1,4 +1,7 @@
#!/usr/bin/env perl
#!/usr/bin/env perl -w

use strict;
use warnings;

use Config;
use Cwd;
Expand All @@ -15,7 +18,9 @@
$GIT
$HELP
$JAVA_HOME
@JAVA_SEARCH_DIRS
$MVN
$MAVEN_VERSION
$MAVEN_OPTS
$PATHSEP
$PREFIX
Expand All @@ -30,11 +35,21 @@
$VERBOSE = undef;
@ARGS = ();

@JAVA_SEARCH_DIRS = qw(
/usr/lib/jvm
/usr/java
/System/Library/Java/JavaVirtualMachines
/Library/Java/JavaVirtualMachines
/Library/Java/Home
/opt
);

eval {
setpriority(0, 0, 10);
};

if (not defined $PATHSEP) { $PATHSEP = ':'; }
die "\$PREFIX not set!" unless (defined $PREFIX);

# If we were called from bin, remove the /bin so we're always
# rooted in the top-of-tree
Expand All @@ -44,24 +59,7 @@
$PREFIX = File::Spec->catdir(@dirs);
}

# path to git executable
$GIT = $ENV{'GIT'};
if (not defined $GIT or not -x $GIT) {
for my $dir (File::Spec->path()) {
my $git = File::Spec->catfile($dir, 'git');
if ($^O =~ /(mswin|msys)/i) {
$git .= '.exe';
}
if (-x $git) {
$GIT = $git;
break;
}
}
}
if ($GIT eq "" or ! -x "$GIT") {
warning("Unable to locate git.");
$GIT = undef;
}
$GIT = find_git();

# path to maven executable
$MVN = $ENV{'MVN'};
Expand Down Expand Up @@ -115,16 +113,29 @@ END
exit 1;
}

if ((defined $JAVA_HOME and -d $JAVA_HOME) or (exists $ENV{'JAVA_HOME'} and -d $ENV{'JAVA_HOME'})) {
if (not defined $JAVA_HOME or not -d $JAVA_HOME) {
$JAVA_HOME = $ENV{'JAVA_HOME'};
}

my ($shortversion) = get_version_from_java(File::Spec->catfile($JAVA_HOME, 'bin', 'java'));
my $minimumversion = get_minimum_java();

if ($shortversion < $minimumversion) {
die "You specified a Java home of $JAVA_HOME, but it does not meet minimum java version $minimumversion!\n";
}
}

if (not defined $JAVA_HOME or $JAVA_HOME eq "") {
debug("--java-home not passed, searching for \$JAVA_HOME");
if (exists $ENV{'JAVA_HOME'} and -e $ENV{'JAVA_HOME'} and $ENV{'JAVA_HOME'} ne "") {
$JAVA_HOME = $ENV{'JAVA_HOME'};
} else {
$JAVA_HOME = find_java_home();
if (not defined $JAVA_HOME) {
warning("\$JAVA_HOME is not set, things might go wonky. Or not.");
}
}

if (defined $JAVA_HOME and $JAVA_HOME ne "") {
info("Using \$JAVA_HOME=$JAVA_HOME");
$ENV{'JAVA_HOME'} = $JAVA_HOME;
$ENV{'PATH'} = File::Spec->catfile($JAVA_HOME, 'bin') . $PATHSEP . $ENV{'PATH'};
}
Expand Down Expand Up @@ -192,6 +203,126 @@ END
$git_branch =~ s,^refs/heads/,,;
info("Git Branch = $git_branch");

sub find_git {
my $git = $ENV{'GIT'};

if (not defined $git or not -x $git) {
for my $dir (File::Spec->path()) {
my $g = File::Spec->catfile($dir, 'git');
if ($^O =~ /(mswin|msys)/i) {
$g .= '.exe';
}
if (-x $g) {
return $g;
}
}
}

if ($git eq "" or ! -x $git) {
warning("Unable to locate git.");
$git = undef;
}
return $git;
}

sub get_minimum_java {
my $minimum_java = '1.6';

my $pomfile = File::Spec->catfile($PREFIX, 'pom.xml');
if (-e $pomfile) {
open(POMFILE, $pomfile) or die "Unable to read $pomfile: $!\n";
while (<POMFILE>) {
if (/<source>([\d\.]+)<\/source>/) {
$minimum_java = $1;
last;
}
}
close(POMFILE) or die "Unable to close $pomfile: $!\n";
}

return $minimum_java;
}

sub get_version_from_java {
my $javacmd = shift;

if (not defined $javacmd or not -x $javacmd) {
return ();
}

my ($output, $bindir, $shortversion, $version, $build, $java_home);

$output = `"$javacmd" -version 2>\&1`;
($version) = $output =~ / version \"?([\d\.]+?(?:[\-\_]\S+?)?)\"?$/ms;
($version, $build) = $version =~ /^([\d\.]+)(?:[\-\_](.*?))?$/;
($shortversion) = $version =~ /^(\d+\.\d+)/;
$build = 0 if (not defined $build);

$bindir = dirname($javacmd);
$java_home = Cwd::realpath(File::Spec->catdir($bindir, '..'));

return ($shortversion, $version, $build, $java_home);
}

sub find_java_home {
my $minimum_java = get_minimum_java();

my $versions = {};
my $javacmd = 'java';

if ($^O =~ /(mswin|msys)/i) {
$javacmd .= '.exe';
}

for my $searchdir (@JAVA_SEARCH_DIRS) {
my @javas = (
glob(File::Spec->catfile($searchdir, 'bin', $javacmd)),
glob(File::Spec->catfile($searchdir, '*', 'bin', $javacmd)),
glob(File::Spec->catfile($searchdir, '*', '*', 'bin', $javacmd)),
glob(File::Spec->catfile($searchdir, '*', '*', '*', 'bin', $javacmd)),
glob(File::Spec->catfile($searchdir, '*', '*', '*', '*', 'bin', $javacmd))
);

for my $java (@javas) {
if (-x $java and ! -d $java) {
my ($shortversion, $version, $build, $java_home) = get_version_from_java($java);
next if (exists $versions->{$shortversion}->{$version}->{$build});

$versions->{$shortversion}->{$version}->{$build} = $java_home;
}
}
}

my $highest_valid = undef;

for my $majorversion (sort keys %$versions) {
if ($majorversion < $minimum_java) {
next;
}

#print STDERR "Java $majorversion:\n";
JDK_SEARCH: for my $version (sort keys %{$versions->{$majorversion}}) {
#print STDERR " $version:\n";
for my $build (sort keys %{$versions->{$majorversion}->{$version}}) {
my $java_home = $versions->{$majorversion}->{$version}->{$build};
#print STDERR " ", $build, ": ", $java_home, "\n";
if ($build =~ /^\d/) {
$highest_valid = $java_home;
} elsif (defined $highest_valid) {
last JDK_SEARCH;
}
}
}

if (defined $highest_valid) {
# we've matched in this version, don't bother looking at higher JDKs
last;
}
}

return $highest_valid;
}

sub clean_git {
if (-d '.git') {
my @command = ($GIT, "clean", "-fdx", ".");
Expand Down Expand Up @@ -231,6 +362,8 @@ sub get_dependencies {
org\.opennms\.smslib\:smslib
);

my $old_version;
my $old_module;
my $moduledir = $PREFIX . "/" . $directory;
my $deps = { 'org.opennms:opennms' => 1 };
my $versions = {};
Expand Down
21 changes: 21 additions & 0 deletions core/schema/src/main/liquibase/1.13.3/changelog.xml
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
xsi:schemaLocation="
http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-2.0.xsd
http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd
">

<changeSet author="ranger@opennms.org" id="1.13.3-pathOutage-ipv6">

<modifyDataType tableName="pathoutage" columnName="criticalpathip" newDataType="text" />

<rollback>
<modifyDataType tableName="pathoutage" columnName="criticalpathip" newDataType="varchar(16)" />
</rollback>

</changeSet>

</databaseChangeLog>
1 change: 1 addition & 0 deletions core/schema/src/main/liquibase/changelog.xml
Expand Up @@ -64,6 +64,7 @@
<include file="1.12.6/changelog.xml"/>
<include file="1.13.0/changelog.xml"/>
<include file="1.13.1/changelog.xml"/>
<include file="1.13.3/changelog.xml"/>

<include file="stored-procedures/getManagePercentAvailIntfWindow.xml" />
<include file="stored-procedures/getManagePercentAvailNodeWindow.xml" />
Expand Down
Expand Up @@ -145,7 +145,7 @@ public int hashCode() {
public String toString() {
StringBuffer buf = new StringBuffer(length()*2+10); // a guess at the str len
for(int i = 0; i < length(); i++) {
if (i != 0 || addPrefixDotInToString()) {
if (i > 0 || addPrefixDotInToString()) {
buf.append('.');
}
buf.append(m_ids[i]);
Expand Down
Expand Up @@ -66,7 +66,7 @@ class SnmpTimer extends Object {
* Used to track the individual runnables and when the runnable "expires".
*
*/
private class TimeoutElement {
private static class TimeoutElement {
/**
* The runnable object
*/
Expand Down
Expand Up @@ -75,6 +75,7 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.annotation.Transactional;

/**
* The Class TcaCollectorTest.
Expand All @@ -92,6 +93,7 @@
@JUnitConfigurationEnvironment
@JUnitTemporaryDatabase(reuseDatabase=false)
@JUnitSnmpAgent(host = TcaCollectorTest.TEST_NODE_IP, port = 9161, resource = "classpath:juniperTcaSample.properties")
@Transactional
public class TcaCollectorTest implements InitializingBean {

/** The Constant TEST_NODE_IP. */
Expand Down
Expand Up @@ -37,8 +37,6 @@
import org.junit.runner.RunWith;
import org.opennms.core.test.ConfigurationTestUtils;
import org.opennms.netmgt.EventConstants;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import org.opennms.netmgt.correlation.CorrelationEngineRegistrar;
import org.opennms.netmgt.correlation.drools.DroolsCorrelationEngine;
import org.opennms.netmgt.dao.mock.EventAnticipator;
Expand All @@ -49,6 +47,8 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.transaction.annotation.Transactional;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations={
Expand All @@ -61,6 +61,7 @@
"classpath:test-context.xml"
})
@JUnitConfigurationEnvironment
@Transactional
public abstract class CorrelationRulesTestCase {

@Autowired
Expand Down
Expand Up @@ -473,15 +473,15 @@ public String getHelp() {
return buffer.toString();
}

public class OutboundNotification implements IOutboundMessageNotification {
public static class OutboundNotification implements IOutboundMessageNotification {
@Override
public void process(AGateway gateway, OutboundMessage msg) {
LOG.debug("Outbound handler called from Gateway: {}", gateway.getGatewayId());
LOG.debug(msg.toString());
}
}

public class InboundNotification implements IInboundMessageNotification{
public static class InboundNotification implements IInboundMessageNotification{

@Override
public void process(AGateway gateway, MessageTypes msgType, InboundMessage msg) {
Expand All @@ -495,7 +495,7 @@ public void process(AGateway gateway, MessageTypes msgType, InboundMessage msg)
}
}

public class CallNotification implements ICallNotification{
public static class CallNotification implements ICallNotification{

@Override
public void process(AGateway gateway, String callerId) {
Expand All @@ -504,7 +504,7 @@ public void process(AGateway gateway, String callerId) {

}

public class GatewayStatusNotification implements IGatewayStatusNotification{
public static class GatewayStatusNotification implements IGatewayStatusNotification{

@Override
public void process(AGateway gateway, GatewayStatuses oldStatus, GatewayStatuses newStatus) {
Expand Down
Expand Up @@ -16,6 +16,7 @@
import org.opennms.test.JUnitConfigurationEnvironment;
import org.springframework.core.io.ByteArrayResource;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.transaction.annotation.Transactional;

@RunWith(OpenNMSJUnit4ClassRunner.class)
@ContextConfiguration(locations={
Expand All @@ -26,6 +27,7 @@
})
@JUnitConfigurationEnvironment
@JUnitTemporaryDatabase
@Transactional
public class ReportPluginTestCase {
@Resource(name="serviceRegistry")
private ServiceRegistry m_defaultServiceRegistry;
Expand Down

0 comments on commit c9948fe

Please sign in to comment.