Branch 'VADER' - java/code
by Mike McCune
java/code/src/com/redhat/rhn/common/util/MD5Sum.java | 2 --
1 file changed, 2 deletions(-)
New commits:
commit 65cf4704f2602c4e44802d69212afc3b8cf0e41e
Author: Mike McCune <mmccune(a)redhat.com>
Date: Wed Aug 12 13:49:00 2009 -0700
514305 - checkstyle
diff --git a/java/code/src/com/redhat/rhn/common/util/MD5Sum.java b/java/code/src/com/redhat/rhn/common/util/MD5Sum.java
index 01abe50..709088d 100644
--- a/java/code/src/com/redhat/rhn/common/util/MD5Sum.java
+++ b/java/code/src/com/redhat/rhn/common/util/MD5Sum.java
@@ -14,9 +14,7 @@
*/
package com.redhat.rhn.common.util;
-import java.io.ByteArrayOutputStream;
import java.io.File;
-import java.io.FileInputStream;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
14 years, 9 months
Branch 'VADER' - java/code
by jdob
java/code/src/com/redhat/rhn/frontend/events/SsmUpgradePackagesAction.java | 24 +++++++++-
1 file changed, 22 insertions(+), 2 deletions(-)
New commits:
commit b29679820e325f50c4176bdd25d28a6aee1e385e
Author: Jason Dobies <jason.dobies(a)redhat.com>
Date: Wed Aug 12 16:18:36 2009 -0400
517076 - Added association of servers in the SSM to the package upgrade task log. See comment in the code for more information.
diff --git a/java/code/src/com/redhat/rhn/frontend/events/SsmUpgradePackagesAction.java b/java/code/src/com/redhat/rhn/frontend/events/SsmUpgradePackagesAction.java
index fc354bc..5647b81 100644
--- a/java/code/src/com/redhat/rhn/frontend/events/SsmUpgradePackagesAction.java
+++ b/java/code/src/com/redhat/rhn/frontend/events/SsmUpgradePackagesAction.java
@@ -29,6 +29,7 @@ import com.redhat.rhn.domain.user.User;
import com.redhat.rhn.domain.user.UserFactory;
import com.redhat.rhn.manager.action.ActionManager;
import com.redhat.rhn.manager.ssm.SsmOperationManager;
+import com.redhat.rhn.manager.rhnset.RhnSetDecl;
/**
* Handles removing packages from servers in the SSM.
@@ -46,9 +47,28 @@ public class SsmUpgradePackagesAction extends AbstractDatabaseAction {
SsmUpgradePackagesEvent event = (SsmUpgradePackagesEvent) msg;
User user = UserFactory.lookupById(event.getUserId());
+ /* The following isn't 100% accurate. All systems in the SSM are associated
+ with the operation, however only systems on which the package already exists
+ (since this is an upgrade) will actually have events scheduled.
+
+ The problem is that the list of servers to which the package upgrades apply
+ is never stored in an RhnSet, which is used to make the impact of this call
+ minimal. The correct list is showed to the user before selecting confirm,
+ so the only potential issue is in viewing the SSM task log after the user
+ has confirmed the operation. Again, the events themselves are correctly
+ scheduled on only the systems to which they apply.
+
+ For now, this small potential for logging inaccuracy is acceptable given the
+ proxmity of this fix to the Satellite 5.3 release (as opposed to omitting
+ the server association to the task entirely).
+
+ jdobies, Aug 12, 2009
+ */
+
LocalizationService ls = LocalizationService.getInstance();
- long operationId = SsmOperationManager.createOperation(user,
- ls.getMessage("ssm.package.upgrade.operationname"), null);
+ String operationMessage = ls.getMessage("ssm.package.upgrade.operationname");
+ long operationId = SsmOperationManager.createOperation(user, operationMessage,
+ RhnSetDecl.SYSTEMS.getLabel());
// Explicitly call handle transactions here so the operation creation above
// is persisted before the potentially long running logic below
14 years, 9 months
java/code
by jdob
java/code/src/com/redhat/rhn/frontend/events/SsmUpgradePackagesAction.java | 24 +++++++++-
1 file changed, 22 insertions(+), 2 deletions(-)
New commits:
commit 7e563acb0e8775e23d00d9a7464f165399452fd9
Author: Jason Dobies <jason.dobies(a)redhat.com>
Date: Wed Aug 12 16:18:36 2009 -0400
517076 - Added association of servers in the SSM to the package upgrade task log. See comment in the code for more information.
diff --git a/java/code/src/com/redhat/rhn/frontend/events/SsmUpgradePackagesAction.java b/java/code/src/com/redhat/rhn/frontend/events/SsmUpgradePackagesAction.java
index fc354bc..5647b81 100644
--- a/java/code/src/com/redhat/rhn/frontend/events/SsmUpgradePackagesAction.java
+++ b/java/code/src/com/redhat/rhn/frontend/events/SsmUpgradePackagesAction.java
@@ -29,6 +29,7 @@ import com.redhat.rhn.domain.user.User;
import com.redhat.rhn.domain.user.UserFactory;
import com.redhat.rhn.manager.action.ActionManager;
import com.redhat.rhn.manager.ssm.SsmOperationManager;
+import com.redhat.rhn.manager.rhnset.RhnSetDecl;
/**
* Handles removing packages from servers in the SSM.
@@ -46,9 +47,28 @@ public class SsmUpgradePackagesAction extends AbstractDatabaseAction {
SsmUpgradePackagesEvent event = (SsmUpgradePackagesEvent) msg;
User user = UserFactory.lookupById(event.getUserId());
+ /* The following isn't 100% accurate. All systems in the SSM are associated
+ with the operation, however only systems on which the package already exists
+ (since this is an upgrade) will actually have events scheduled.
+
+ The problem is that the list of servers to which the package upgrades apply
+ is never stored in an RhnSet, which is used to make the impact of this call
+ minimal. The correct list is showed to the user before selecting confirm,
+ so the only potential issue is in viewing the SSM task log after the user
+ has confirmed the operation. Again, the events themselves are correctly
+ scheduled on only the systems to which they apply.
+
+ For now, this small potential for logging inaccuracy is acceptable given the
+ proxmity of this fix to the Satellite 5.3 release (as opposed to omitting
+ the server association to the task entirely).
+
+ jdobies, Aug 12, 2009
+ */
+
LocalizationService ls = LocalizationService.getInstance();
- long operationId = SsmOperationManager.createOperation(user,
- ls.getMessage("ssm.package.upgrade.operationname"), null);
+ String operationMessage = ls.getMessage("ssm.package.upgrade.operationname");
+ long operationId = SsmOperationManager.createOperation(user, operationMessage,
+ RhnSetDecl.SYSTEMS.getLabel());
// Explicitly call handle transactions here so the operation creation above
// is persisted before the potentially long running logic below
14 years, 9 months
Branch 'VADER' - java/buildconf java/code java/ivy.xml
by Mike McCune
java/buildconf/build-props.xml | 2
java/buildconf/build-utils.xml | 2
java/code/src/com/redhat/rhn/common/util/MD5Sum.java | 23 -----
java/code/src/com/redhat/rhn/common/util/test/MD5SumTest.java | 40 +++++++++-
java/code/src/com/redhat/rhn/testing/TestUtils.java | 27 ++++++
java/ivy.xml | 1
6 files changed, 71 insertions(+), 24 deletions(-)
New commits:
commit a77cbced5176518088c8090667138c5d74f982df
Author: Mike McCune <mmccune(a)redhat.com>
Date: Wed Aug 12 13:12:45 2009 -0700
514305 - switching the algorithm for reading the file into memory.
New algorithm ditches the ByteArrayOutputStream which has its own
internal byte array buffer which means we are maintaining 2x
copies of the file in memory which doubles the heap required.
diff --git a/java/buildconf/build-props.xml b/java/buildconf/build-props.xml
index 17c0bc2..2854c1e 100644
--- a/java/buildconf/build-props.xml
+++ b/java/buildconf/build-props.xml
@@ -52,7 +52,7 @@
<property name="common.jar.dependencies"
value="bcel cglib commons-beanutils commons-cli commons-codec
commons-collections commons-digester commons-discovery
- commons-el commons-lang commons-logging commons-validator hibernate3
+ commons-el commons-lang commons-logging commons-io commons-validator hibernate3
mailapi smtp jdom jpam
jspapi log4j oro redstone-xmlrpc-client redstone-xmlrpc servletapi5 struts
bcprov bcpg jcommon stringtree-json
diff --git a/java/buildconf/build-utils.xml b/java/buildconf/build-utils.xml
index e4e16a9..16be3d5 100644
--- a/java/buildconf/build-utils.xml
+++ b/java/buildconf/build-utils.xml
@@ -60,7 +60,7 @@ Running @{banner} ...
1.6.2, remove forkmode attribute -->
<junit forkmode="once" fork="yes" printsummary="off" showoutput="yes"
haltonfailure="${halt-tests-on-failure}"
- failureproperty="junit_test_failure" >
+ failureproperty="junit_test_failure" maxmemory="256m">
<!-- kind of hokey, but we need a property for the DataSourceParser
test to work. This keeps people from breaking until we move
the DataSource xml files into rhn-java. -->
diff --git a/java/code/src/com/redhat/rhn/common/util/MD5Sum.java b/java/code/src/com/redhat/rhn/common/util/MD5Sum.java
index 5d5c4cd..01abe50 100644
--- a/java/code/src/com/redhat/rhn/common/util/MD5Sum.java
+++ b/java/code/src/com/redhat/rhn/common/util/MD5Sum.java
@@ -142,28 +142,11 @@ public class MD5Sum {
*/
public static String getFileMD5Sum(File f) throws IOException {
String sum = null;
- FileInputStream in = new FileInputStream(f.getAbsolutePath());
- byte[] b = new byte[1024];
- int num = 0;
- ByteArrayOutputStream out = new ByteArrayOutputStream();
-
- while ((num = in.read(b)) != -1) {
- out.write(b, 0, num);
-
- if (out.size() > SCOUR_MD5_BYTE_LIMIT) {
- sum = md5Sum(out.toByteArray(), SCOUR_MD5_BYTE_LIMIT);
- break;
- }
- }
-
- if (sum == null) {
- sum = md5Sum(out.toByteArray(), SCOUR_MD5_BYTE_LIMIT);
- }
-
- in.close();
- out.close();
+ byte[] barray = FileUtils.readByteArrayFromFile(f, 0, f.length());
+ sum = md5Sum(barray, SCOUR_MD5_BYTE_LIMIT);
return sum;
}
+
}
diff --git a/java/code/src/com/redhat/rhn/common/util/test/MD5SumTest.java b/java/code/src/com/redhat/rhn/common/util/test/MD5SumTest.java
index 7e97efe..2e5bdfd 100644
--- a/java/code/src/com/redhat/rhn/common/util/test/MD5SumTest.java
+++ b/java/code/src/com/redhat/rhn/common/util/test/MD5SumTest.java
@@ -15,21 +15,57 @@
package com.redhat.rhn.common.util.test;
import com.redhat.rhn.common.util.MD5Sum;
-import com.redhat.rhn.testing.RhnBaseTestCase;
import com.redhat.rhn.testing.TestUtils;
import java.io.File;
+import java.util.Random;
+
+import junit.framework.TestCase;
/**
* @author mmccune
*
*/
-public class MD5SumTest extends RhnBaseTestCase {
+public class MD5SumTest extends TestCase {
public void testMD5Sum() throws Exception {
File testFile = new File(TestUtils.findTestData("test.file").getFile());
String sum = MD5Sum.getFileMD5Sum(testFile);
assertEquals("ab0aa62f30d67085cd07ea9004a1437f", sum);
}
+
+ /**
+ * Note that this test creates a large 100MB file in /tmp
+ * and then does an md5sum on the file.
+ *
+ * With a previous implementation of MD5Sum.getFileMD5Sum() this would
+ * cause an OOME with a max-heap size in junit of 256m. This is configured in:
+ * spacewalk/buildconf/build-utils.xml:
+ *
+ * <junit forkmode="once" fork="yes" printsummary="off" showoutput="yes"
+ * haltonfailure="${halt-tests-on-failure}"
+ * failureproperty="junit_test_failure" maxmemory="256m">
+ *
+ * The new implementation uses less memory and thus passes the test below when ran
+ * from Junit CLI.
+ *
+ * @throws Exception
+ */
+ public void testOOMEMD5Sum() throws Exception {
+ File large = new File("/tmp/large-file.dat");
+ // Create a large 100mb file
+ large.createNewFile();
+ writeRandomLargeBytesToFile(large);
+ String sum = MD5Sum.getFileMD5Sum(large);
+ assertNotNull(sum);
+ large.delete();
+ }
+
+ private static void writeRandomLargeBytesToFile(File f) {
+ byte[] ba = new byte[101326592];
+ Random r = new Random();
+ r.nextBytes(ba);
+ TestUtils.writeByteArrayToFile(f, ba);
+ }
}
diff --git a/java/code/src/com/redhat/rhn/testing/TestUtils.java b/java/code/src/com/redhat/rhn/testing/TestUtils.java
index b5df56d..a021c8c 100644
--- a/java/code/src/com/redhat/rhn/testing/TestUtils.java
+++ b/java/code/src/com/redhat/rhn/testing/TestUtils.java
@@ -43,6 +43,8 @@ import org.hibernate.Query;
import org.hibernate.Session;
import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
@@ -88,6 +90,31 @@ public class TestUtils {
}
/**
+ * Write a byte array to a file
+ * @param file to write bytearray to
+ * @param array to write out
+ */
+ public static void writeByteArrayToFile(File file, byte[] array) {
+ try {
+ if (file.exists()) {
+ file.delete();
+ }
+ file.createNewFile();
+ FileOutputStream fos = new FileOutputStream(file);
+ try {
+ fos.write(array);
+ }
+ finally {
+ fos.close();
+ }
+ }
+ catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+
+ /**
* Read whole stream into a string.
*
* @param stream the stream to consume
diff --git a/java/ivy.xml b/java/ivy.xml
index f3c990e..1eb79b6 100644
--- a/java/ivy.xml
+++ b/java/ivy.xml
@@ -22,6 +22,7 @@
<dependency org="redhat" name="commons-httpclient" rev="3.0" />
<dependency org="redhat" name="commons-lang" rev="2.1" />
<dependency org="redhat" name="commons-logging" rev="1.0.4" />
+ <dependency org="redhat" name="commons-io" rev="1.3.2" />
<dependency org="redhat" name="commons-validator" rev="1.1.4" />
<dependency org="redhat" name="concurrent" rev="1.3.2" />
<dependency org="redhat" name="dom4j" rev="1.6.1" />
14 years, 9 months
Branch 'VADER' - java/code
by jdob
java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml | 3 +++
java/code/webapp/WEB-INF/pages/ssm/view-log.jsp | 1 +
2 files changed, 4 insertions(+)
New commits:
commit b19aecec10cbdb2bd6562dc906ba222be21e9f58
Author: Jason Dobies <jason.dobies(a)redhat.com>
Date: Wed Aug 12 15:21:08 2009 -0400
517086 - Added note to indicate the types of SSM tasks to expect to see on that page to minimize confusion.
diff --git a/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml b/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml
index 2081dec..faaab7b 100644
--- a/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml
+++ b/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml
@@ -16031,6 +16031,9 @@ any of these revisions. Are you sure you want to do this?</source>
<trans-unit id="ssm.operations.completed.summary">
<source>The following lists all tasks that have finished running. Click on an task's description to see more details.</source>
</trans-unit>
+ <trans-unit id="ssm.operations.viewlog.note">
+ <source>Note: only child channel subscription changes and package install/remove/upgrade/verify tasks are listed.</source>
+ </trans-unit>
</group>
<!-- ssm/packages.jsp -->
diff --git a/java/code/webapp/WEB-INF/pages/ssm/view-log.jsp b/java/code/webapp/WEB-INF/pages/ssm/view-log.jsp
index d4f7f69..8c05267 100644
--- a/java/code/webapp/WEB-INF/pages/ssm/view-log.jsp
+++ b/java/code/webapp/WEB-INF/pages/ssm/view-log.jsp
@@ -29,6 +29,7 @@
<div class="page-summary">
<p><bean:message key="${summaryKey}"/></p>
+ <p><bean:message key="ssm.operations.viewlog.note"/></p>
</div>
<rl:listset name="groupSet">
14 years, 9 months
java/code
by jdob
java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml | 3 +++
java/code/webapp/WEB-INF/pages/ssm/view-log.jsp | 1 +
2 files changed, 4 insertions(+)
New commits:
commit 2a41221364b2a2b8adda75b30ac8b5850c7ac2ca
Author: Jason Dobies <jason.dobies(a)redhat.com>
Date: Wed Aug 12 15:21:08 2009 -0400
517086 - Added note to indicate the types of SSM tasks to expect to see on that page to minimize confusion.
diff --git a/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml b/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml
index 9fe252a..f00d191 100644
--- a/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml
+++ b/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml
@@ -16056,6 +16056,9 @@ any of these revisions. Are you sure you want to do this?</source>
<trans-unit id="ssm.operations.completed.summary">
<source>The following lists all tasks that have finished running. Click on an task's description to see more details.</source>
</trans-unit>
+ <trans-unit id="ssm.operations.viewlog.note">
+ <source>Note: only child channel subscription changes and package install/remove/upgrade/verify tasks are listed.</source>
+ </trans-unit>
</group>
<!-- ssm/packages.jsp -->
diff --git a/java/code/webapp/WEB-INF/pages/ssm/view-log.jsp b/java/code/webapp/WEB-INF/pages/ssm/view-log.jsp
index e30af44..ae04339 100644
--- a/java/code/webapp/WEB-INF/pages/ssm/view-log.jsp
+++ b/java/code/webapp/WEB-INF/pages/ssm/view-log.jsp
@@ -21,6 +21,7 @@
<div class="page-summary">
<p><bean:message key="${summaryKey}"/></p>
+ <p><bean:message key="ssm.operations.viewlog.note"/></p>
</div>
<rl:listset name="groupSet">
14 years, 9 months
java/buildconf java/code java/ivy.xml
by Mike McCune
java/buildconf/build-props.xml | 2
java/buildconf/build-utils.xml | 2
java/code/src/com/redhat/rhn/common/util/MD5Sum.java | 23 -----
java/code/src/com/redhat/rhn/common/util/test/MD5SumTest.java | 40 +++++++++-
java/code/src/com/redhat/rhn/testing/TestUtils.java | 27 ++++++
java/ivy.xml | 1
6 files changed, 71 insertions(+), 24 deletions(-)
New commits:
commit 1f617dc25a0bd3551fc112e366d9a24e6ee05345
Author: Mike McCune <mmccune(a)redhat.com>
Date: Wed Aug 12 11:40:02 2009 -0700
514305 - switching the algorithm for reading the file into memory.
New algorithm ditches the ByteArrayOutputStream which has its own
internal byte array buffer which means we are maintaining 2x
copies of the file in memory which doubles the heap required.
diff --git a/java/buildconf/build-props.xml b/java/buildconf/build-props.xml
index c23c3bc..8d6576c 100644
--- a/java/buildconf/build-props.xml
+++ b/java/buildconf/build-props.xml
@@ -52,7 +52,7 @@
<property name="common.jar.dependencies"
value="bcel cglib commons-beanutils commons-cli commons-codec
commons-collections commons-digester commons-discovery
- commons-el commons-lang commons-logging commons-validator hibernate3
+ commons-el commons-lang commons-logging commons-io commons-validator hibernate3
mailapi smtp jdom jpam
jspapi log4j oro redstone-xmlrpc-client redstone-xmlrpc servletapi5 struts
bcprov bcpg jcommon stringtree-json postgresql-jdbc
diff --git a/java/buildconf/build-utils.xml b/java/buildconf/build-utils.xml
index e4e16a9..16be3d5 100644
--- a/java/buildconf/build-utils.xml
+++ b/java/buildconf/build-utils.xml
@@ -60,7 +60,7 @@ Running @{banner} ...
1.6.2, remove forkmode attribute -->
<junit forkmode="once" fork="yes" printsummary="off" showoutput="yes"
haltonfailure="${halt-tests-on-failure}"
- failureproperty="junit_test_failure" >
+ failureproperty="junit_test_failure" maxmemory="256m">
<!-- kind of hokey, but we need a property for the DataSourceParser
test to work. This keeps people from breaking until we move
the DataSource xml files into rhn-java. -->
diff --git a/java/code/src/com/redhat/rhn/common/util/MD5Sum.java b/java/code/src/com/redhat/rhn/common/util/MD5Sum.java
index 5d5c4cd..01abe50 100644
--- a/java/code/src/com/redhat/rhn/common/util/MD5Sum.java
+++ b/java/code/src/com/redhat/rhn/common/util/MD5Sum.java
@@ -142,28 +142,11 @@ public class MD5Sum {
*/
public static String getFileMD5Sum(File f) throws IOException {
String sum = null;
- FileInputStream in = new FileInputStream(f.getAbsolutePath());
- byte[] b = new byte[1024];
- int num = 0;
- ByteArrayOutputStream out = new ByteArrayOutputStream();
-
- while ((num = in.read(b)) != -1) {
- out.write(b, 0, num);
-
- if (out.size() > SCOUR_MD5_BYTE_LIMIT) {
- sum = md5Sum(out.toByteArray(), SCOUR_MD5_BYTE_LIMIT);
- break;
- }
- }
-
- if (sum == null) {
- sum = md5Sum(out.toByteArray(), SCOUR_MD5_BYTE_LIMIT);
- }
-
- in.close();
- out.close();
+ byte[] barray = FileUtils.readByteArrayFromFile(f, 0, f.length());
+ sum = md5Sum(barray, SCOUR_MD5_BYTE_LIMIT);
return sum;
}
+
}
diff --git a/java/code/src/com/redhat/rhn/common/util/test/MD5SumTest.java b/java/code/src/com/redhat/rhn/common/util/test/MD5SumTest.java
index 7e97efe..2e5bdfd 100644
--- a/java/code/src/com/redhat/rhn/common/util/test/MD5SumTest.java
+++ b/java/code/src/com/redhat/rhn/common/util/test/MD5SumTest.java
@@ -15,21 +15,57 @@
package com.redhat.rhn.common.util.test;
import com.redhat.rhn.common.util.MD5Sum;
-import com.redhat.rhn.testing.RhnBaseTestCase;
import com.redhat.rhn.testing.TestUtils;
import java.io.File;
+import java.util.Random;
+
+import junit.framework.TestCase;
/**
* @author mmccune
*
*/
-public class MD5SumTest extends RhnBaseTestCase {
+public class MD5SumTest extends TestCase {
public void testMD5Sum() throws Exception {
File testFile = new File(TestUtils.findTestData("test.file").getFile());
String sum = MD5Sum.getFileMD5Sum(testFile);
assertEquals("ab0aa62f30d67085cd07ea9004a1437f", sum);
}
+
+ /**
+ * Note that this test creates a large 100MB file in /tmp
+ * and then does an md5sum on the file.
+ *
+ * With a previous implementation of MD5Sum.getFileMD5Sum() this would
+ * cause an OOME with a max-heap size in junit of 256m. This is configured in:
+ * spacewalk/buildconf/build-utils.xml:
+ *
+ * <junit forkmode="once" fork="yes" printsummary="off" showoutput="yes"
+ * haltonfailure="${halt-tests-on-failure}"
+ * failureproperty="junit_test_failure" maxmemory="256m">
+ *
+ * The new implementation uses less memory and thus passes the test below when ran
+ * from Junit CLI.
+ *
+ * @throws Exception
+ */
+ public void testOOMEMD5Sum() throws Exception {
+ File large = new File("/tmp/large-file.dat");
+ // Create a large 100mb file
+ large.createNewFile();
+ writeRandomLargeBytesToFile(large);
+ String sum = MD5Sum.getFileMD5Sum(large);
+ assertNotNull(sum);
+ large.delete();
+ }
+
+ private static void writeRandomLargeBytesToFile(File f) {
+ byte[] ba = new byte[101326592];
+ Random r = new Random();
+ r.nextBytes(ba);
+ TestUtils.writeByteArrayToFile(f, ba);
+ }
}
diff --git a/java/code/src/com/redhat/rhn/testing/TestUtils.java b/java/code/src/com/redhat/rhn/testing/TestUtils.java
index b5df56d..a021c8c 100644
--- a/java/code/src/com/redhat/rhn/testing/TestUtils.java
+++ b/java/code/src/com/redhat/rhn/testing/TestUtils.java
@@ -43,6 +43,8 @@ import org.hibernate.Query;
import org.hibernate.Session;
import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
@@ -88,6 +90,31 @@ public class TestUtils {
}
/**
+ * Write a byte array to a file
+ * @param file to write bytearray to
+ * @param array to write out
+ */
+ public static void writeByteArrayToFile(File file, byte[] array) {
+ try {
+ if (file.exists()) {
+ file.delete();
+ }
+ file.createNewFile();
+ FileOutputStream fos = new FileOutputStream(file);
+ try {
+ fos.write(array);
+ }
+ finally {
+ fos.close();
+ }
+ }
+ catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+
+ /**
* Read whole stream into a string.
*
* @param stream the stream to consume
diff --git a/java/ivy.xml b/java/ivy.xml
index 955ea90..7ab8e43 100644
--- a/java/ivy.xml
+++ b/java/ivy.xml
@@ -22,6 +22,7 @@
<dependency org="redhat" name="commons-httpclient" rev="3.0" />
<dependency org="redhat" name="commons-lang" rev="2.1" />
<dependency org="redhat" name="commons-logging" rev="1.0.4" />
+ <dependency org="redhat" name="commons-io" rev="1.3.2" />
<dependency org="redhat" name="commons-validator" rev="1.1.4" />
<dependency org="redhat" name="concurrent" rev="1.3.2" />
<dependency org="redhat" name="dom4j" rev="1.6.1" />
14 years, 9 months
Branch 'VADER' - java/code
by jdob
java/code/src/com/redhat/rhn/common/db/datasource/xml/ssm_operation_queries.xml | 3 +-
java/code/src/com/redhat/rhn/frontend/events/SsmChangeChannelSubscriptionsAction.java | 4 +--
java/code/src/com/redhat/rhn/manager/ssm/SsmOperationManager.java | 11 +++++----
java/code/src/com/redhat/rhn/manager/ssm/test/SsmOperationManagerTest.java | 12 ++++++----
4 files changed, 19 insertions(+), 11 deletions(-)
New commits:
commit 12d14826a4e3bd32c35c3a499849811d0c08462f
Author: Jason Dobies <jason.dobies(a)redhat.com>
Date: Wed Aug 12 14:33:39 2009 -0400
517074 - Systems were pulled from the SSM rhnSet without being scoped to a specific user ID. Updated the query to take user IDs into account.
diff --git a/java/code/src/com/redhat/rhn/common/db/datasource/xml/ssm_operation_queries.xml b/java/code/src/com/redhat/rhn/common/db/datasource/xml/ssm_operation_queries.xml
index 6aafbb9..a530442 100644
--- a/java/code/src/com/redhat/rhn/common/db/datasource/xml/ssm_operation_queries.xml
+++ b/java/code/src/com/redhat/rhn/common/db/datasource/xml/ssm_operation_queries.xml
@@ -109,12 +109,13 @@
This call assumes the server IDs are stored in the set's "element" field.
-->
<write-mode name="map_servers_to_operation">
- <query params="op_id, set_label">
+ <query params="op_id, user_id, set_label">
INSERT INTO rhnSsmOperationServer (operation_id, server_id)
(
SELECT DISTINCT :op_id, s.element
FROM rhnSet s
WHERE label = :set_label
+ AND user_id = :user_id
AND s.element NOT IN
(
SELECT sos.server_id
diff --git a/java/code/src/com/redhat/rhn/frontend/events/SsmChangeChannelSubscriptionsAction.java b/java/code/src/com/redhat/rhn/frontend/events/SsmChangeChannelSubscriptionsAction.java
index 30a9fe4..a3b57e7 100644
--- a/java/code/src/com/redhat/rhn/frontend/events/SsmChangeChannelSubscriptionsAction.java
+++ b/java/code/src/com/redhat/rhn/frontend/events/SsmChangeChannelSubscriptionsAction.java
@@ -49,9 +49,9 @@ public class SsmChangeChannelSubscriptionsAction extends AbstractDatabaseAction
long operationId = SsmOperationManager.createOperation(user,
"Channel Subscription Updates", null);
- SsmOperationManager.associateServersWithOperation(operationId,
+ SsmOperationManager.associateServersWithOperation(operationId, user.getId(),
RhnSetDecl.SSM_CHANNEL_SUBSCRIBE.getLabel());
- SsmOperationManager.associateServersWithOperation(operationId,
+ SsmOperationManager.associateServersWithOperation(operationId, user.getId(),
RhnSetDecl.SSM_CHANNEL_UNSUBSCRIBE.getLabel());
// Do the changes
diff --git a/java/code/src/com/redhat/rhn/manager/ssm/SsmOperationManager.java b/java/code/src/com/redhat/rhn/manager/ssm/SsmOperationManager.java
index 917d187..af7a259 100644
--- a/java/code/src/com/redhat/rhn/manager/ssm/SsmOperationManager.java
+++ b/java/code/src/com/redhat/rhn/manager/ssm/SsmOperationManager.java
@@ -190,7 +190,7 @@ public class SsmOperationManager extends BaseManager {
// Add the server/operation mappings
if (rhnSetLabel != null) {
- associateServersWithOperation(operationId, rhnSetLabel);
+ associateServersWithOperation(operationId, user.getId(), rhnSetLabel);
}
return operationId;
@@ -242,16 +242,19 @@ public class SsmOperationManager extends BaseManager {
* Associates an operation with a group of servers against which it was run, where
* the servers are found in an RhnSet. The IDs for these servers must be stored in
* the "element" field of the RhnSet.
- *
+ *
* @param operationId identifies an existing operation to associate with servers
+ * @param userId identifies the user performing the operation
* @param setLabel identifies the set in which to find server IDs
*/
- public static void associateServersWithOperation(long operationId, String setLabel) {
+ public static void associateServersWithOperation(long operationId, long userId,
+ String setLabel) {
WriteMode writeMode =
ModeFactory.getWriteMode("ssm_operation_queries", "map_servers_to_operation");
- Map<String, Object> params = new HashMap<String, Object>(2);
+ Map<String, Object> params = new HashMap<String, Object>(3);
params.put("op_id", operationId);
+ params.put("user_id", userId);
params.put("set_label", setLabel);
writeMode.executeUpdate(params);
diff --git a/java/code/src/com/redhat/rhn/manager/ssm/test/SsmOperationManagerTest.java b/java/code/src/com/redhat/rhn/manager/ssm/test/SsmOperationManagerTest.java
index e339b38..dc4d8a3 100644
--- a/java/code/src/com/redhat/rhn/manager/ssm/test/SsmOperationManagerTest.java
+++ b/java/code/src/com/redhat/rhn/manager/ssm/test/SsmOperationManagerTest.java
@@ -143,7 +143,8 @@ public class SsmOperationManagerTest extends RhnBaseTestCase {
assertEquals(0, result.size());
// Test
- SsmOperationManager.associateServersWithOperation(operationId, serverSetLabel);
+ SsmOperationManager.associateServersWithOperation(operationId, ssmUser.getId(),
+ serverSetLabel);
// Verify
result = SsmOperationManager.findServerDataForOperation(operationId);
@@ -186,8 +187,10 @@ public class SsmOperationManagerTest extends RhnBaseTestCase {
String secondSetLabel = secondSet.getLabel();
// Test
- SsmOperationManager.associateServersWithOperation(operationId, serverSetLabel);
- SsmOperationManager.associateServersWithOperation(operationId, secondSetLabel);
+ SsmOperationManager.associateServersWithOperation(operationId, ssmUser.getId(),
+ serverSetLabel);
+ SsmOperationManager.associateServersWithOperation(operationId, ssmUser.getId(),
+ secondSetLabel);
// Verify
result = SsmOperationManager.findServerDataForOperation(operationId);
@@ -235,7 +238,8 @@ public class SsmOperationManagerTest extends RhnBaseTestCase {
String secondSetLabel = secondSet.getLabel();
// Test
- SsmOperationManager.associateServersWithOperation(operationId, secondSetLabel);
+ SsmOperationManager.associateServersWithOperation(operationId, ssmUser.getId(),
+ secondSetLabel);
// Verify
result = SsmOperationManager.findServerDataForOperation(operationId);
14 years, 9 months
java/code
by jdob
java/code/src/com/redhat/rhn/common/db/datasource/xml/ssm_operation_queries.xml | 3 +-
java/code/src/com/redhat/rhn/frontend/events/SsmChangeChannelSubscriptionsAction.java | 4 +--
java/code/src/com/redhat/rhn/manager/ssm/SsmOperationManager.java | 11 +++++----
java/code/src/com/redhat/rhn/manager/ssm/test/SsmOperationManagerTest.java | 12 ++++++----
4 files changed, 19 insertions(+), 11 deletions(-)
New commits:
commit a2f9ba58ccca28d9158b11c9f8cd1d91288a3761
Author: Jason Dobies <jason.dobies(a)redhat.com>
Date: Wed Aug 12 14:33:39 2009 -0400
517074 - Systems were pulled from the SSM rhnSet without being scoped to a specific user ID. Updated the query to take user IDs into account.
diff --git a/java/code/src/com/redhat/rhn/common/db/datasource/xml/ssm_operation_queries.xml b/java/code/src/com/redhat/rhn/common/db/datasource/xml/ssm_operation_queries.xml
index 6aafbb9..a530442 100644
--- a/java/code/src/com/redhat/rhn/common/db/datasource/xml/ssm_operation_queries.xml
+++ b/java/code/src/com/redhat/rhn/common/db/datasource/xml/ssm_operation_queries.xml
@@ -109,12 +109,13 @@
This call assumes the server IDs are stored in the set's "element" field.
-->
<write-mode name="map_servers_to_operation">
- <query params="op_id, set_label">
+ <query params="op_id, user_id, set_label">
INSERT INTO rhnSsmOperationServer (operation_id, server_id)
(
SELECT DISTINCT :op_id, s.element
FROM rhnSet s
WHERE label = :set_label
+ AND user_id = :user_id
AND s.element NOT IN
(
SELECT sos.server_id
diff --git a/java/code/src/com/redhat/rhn/frontend/events/SsmChangeChannelSubscriptionsAction.java b/java/code/src/com/redhat/rhn/frontend/events/SsmChangeChannelSubscriptionsAction.java
index 30a9fe4..a3b57e7 100644
--- a/java/code/src/com/redhat/rhn/frontend/events/SsmChangeChannelSubscriptionsAction.java
+++ b/java/code/src/com/redhat/rhn/frontend/events/SsmChangeChannelSubscriptionsAction.java
@@ -49,9 +49,9 @@ public class SsmChangeChannelSubscriptionsAction extends AbstractDatabaseAction
long operationId = SsmOperationManager.createOperation(user,
"Channel Subscription Updates", null);
- SsmOperationManager.associateServersWithOperation(operationId,
+ SsmOperationManager.associateServersWithOperation(operationId, user.getId(),
RhnSetDecl.SSM_CHANNEL_SUBSCRIBE.getLabel());
- SsmOperationManager.associateServersWithOperation(operationId,
+ SsmOperationManager.associateServersWithOperation(operationId, user.getId(),
RhnSetDecl.SSM_CHANNEL_UNSUBSCRIBE.getLabel());
// Do the changes
diff --git a/java/code/src/com/redhat/rhn/manager/ssm/SsmOperationManager.java b/java/code/src/com/redhat/rhn/manager/ssm/SsmOperationManager.java
index 917d187..af7a259 100644
--- a/java/code/src/com/redhat/rhn/manager/ssm/SsmOperationManager.java
+++ b/java/code/src/com/redhat/rhn/manager/ssm/SsmOperationManager.java
@@ -190,7 +190,7 @@ public class SsmOperationManager extends BaseManager {
// Add the server/operation mappings
if (rhnSetLabel != null) {
- associateServersWithOperation(operationId, rhnSetLabel);
+ associateServersWithOperation(operationId, user.getId(), rhnSetLabel);
}
return operationId;
@@ -242,16 +242,19 @@ public class SsmOperationManager extends BaseManager {
* Associates an operation with a group of servers against which it was run, where
* the servers are found in an RhnSet. The IDs for these servers must be stored in
* the "element" field of the RhnSet.
- *
+ *
* @param operationId identifies an existing operation to associate with servers
+ * @param userId identifies the user performing the operation
* @param setLabel identifies the set in which to find server IDs
*/
- public static void associateServersWithOperation(long operationId, String setLabel) {
+ public static void associateServersWithOperation(long operationId, long userId,
+ String setLabel) {
WriteMode writeMode =
ModeFactory.getWriteMode("ssm_operation_queries", "map_servers_to_operation");
- Map<String, Object> params = new HashMap<String, Object>(2);
+ Map<String, Object> params = new HashMap<String, Object>(3);
params.put("op_id", operationId);
+ params.put("user_id", userId);
params.put("set_label", setLabel);
writeMode.executeUpdate(params);
diff --git a/java/code/src/com/redhat/rhn/manager/ssm/test/SsmOperationManagerTest.java b/java/code/src/com/redhat/rhn/manager/ssm/test/SsmOperationManagerTest.java
index e339b38..dc4d8a3 100644
--- a/java/code/src/com/redhat/rhn/manager/ssm/test/SsmOperationManagerTest.java
+++ b/java/code/src/com/redhat/rhn/manager/ssm/test/SsmOperationManagerTest.java
@@ -143,7 +143,8 @@ public class SsmOperationManagerTest extends RhnBaseTestCase {
assertEquals(0, result.size());
// Test
- SsmOperationManager.associateServersWithOperation(operationId, serverSetLabel);
+ SsmOperationManager.associateServersWithOperation(operationId, ssmUser.getId(),
+ serverSetLabel);
// Verify
result = SsmOperationManager.findServerDataForOperation(operationId);
@@ -186,8 +187,10 @@ public class SsmOperationManagerTest extends RhnBaseTestCase {
String secondSetLabel = secondSet.getLabel();
// Test
- SsmOperationManager.associateServersWithOperation(operationId, serverSetLabel);
- SsmOperationManager.associateServersWithOperation(operationId, secondSetLabel);
+ SsmOperationManager.associateServersWithOperation(operationId, ssmUser.getId(),
+ serverSetLabel);
+ SsmOperationManager.associateServersWithOperation(operationId, ssmUser.getId(),
+ secondSetLabel);
// Verify
result = SsmOperationManager.findServerDataForOperation(operationId);
@@ -235,7 +238,8 @@ public class SsmOperationManagerTest extends RhnBaseTestCase {
String secondSetLabel = secondSet.getLabel();
// Test
- SsmOperationManager.associateServersWithOperation(operationId, secondSetLabel);
+ SsmOperationManager.associateServersWithOperation(operationId, ssmUser.getId(),
+ secondSetLabel);
// Verify
result = SsmOperationManager.findServerDataForOperation(operationId);
14 years, 9 months
rel-eng/build-missing-builds-in-koji.sh
by Dennis Gilmore
rel-eng/build-missing-builds-in-koji.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
New commits:
commit a96c1ef72b4b52ddad9edebbe800e59fd0173b30
Author: Dennis Gilmore <dennis(a)ausil.us>
Date: Wed Aug 12 12:48:09 2009 -0500
update to use new build tags
diff --git a/rel-eng/build-missing-builds-in-koji.sh b/rel-eng/build-missing-builds-in-koji.sh
index eeb3644..da85a92 100755
--- a/rel-eng/build-missing-builds-in-koji.sh
+++ b/rel-eng/build-missing-builds-in-koji.sh
@@ -1,6 +1,6 @@
#!/bin/bash
-TAGS=([0]="dist-5E-sw-0.6-candidate" [1]="dist-f10-sw-0.6-candidate" [2]="dist-f11-sw-0.6-candidate")
+TAGS=([0]="dist-5E-sw-0.7-candidate" [1]="dist-f11-sw-0.7-candidate" [2]="dist-f12-sw-0.7-candidate")
pushd `pwd`
14 years, 9 months