[gold-users] gold-users Digest, Vol 54, Issue 3

Ho, Quang quang.ho at hp.com
Wed Aug 24 01:18:10 MDT 2011


Hi Scott,

Thanks very much for your responses.

I have another question about updating custom GOLD object via Perl script.
The same object was created from previous emails.

gold> Object Create Name=TestSchedule Description="Test Schedule"
Successfully created 1 Object
gold> Attribute Create Object=TestSchedule Name=TestDate DataType=TimeStamp
Successfully created 1 Attribute
gold> Attribute Create Object=TestSchedule Name=TestDescription DataType=String
Successfully created 1 Attribute
gold> Action Create Object=TestSchedule Name=Create Display=True Description="Create"
Successfully created 1 Action
gold> Action Create Object=TestSchedule name=Query Display=True Description="Query"
The name is malformed (name).
gold> Action Create Object=TestSchedule Name=Query Display=True Description="Query"
Successfully created 1 Action

This time I used Perl script to populate data into it.

use strict;
use lib "/opt/gold/lib", "/opt/gold/lib/perl5";
use Gold;
my $time = time;

my $updateRequest = new Gold::Request(objects => [new Gold::Object(name=>"TestSchedule")], action => "Create");
my $org = new Gold::Datum("TestSchedule");
$org->setValue("TestDate",$time);
$org->setValue("TestDescription","Gold Testing");
print $org->toString();
$updateRequest->setDatum($org);
my $updateResponse = $updateRequest->getResponse();
print $updateResponse->toString() ."\n";

my $request = new Gold::Request(objects => [new Gold::Object(name=>"TestSchedule")], action => "Query");
$request->setSelection("TestDate");
$request->setSelection("TestDescription");
my $response = $request->getResponse();

foreach my $datum ($response->getData())
{
        print "****** " . $datum->toString(). "\n";
}

The output of the script below:
<TestSchedule><TestDate>1314169364</TestDate><TestDescription>Gold Testing</TestDescription></TestSchedule>(root, Success, 000, Successfully created 1 TestSchedule, 1, [<TestSchedule><TestDate></TestDate><TestDescription></TestDescription></TestSchedule>], 1, 0)
****** <TestSchedule><TestDate></TestDate><TestDescription></TestDescription></TestSchedule>
****** <TestSchedule><TestDate></TestDate><TestDescription></TestDescription></TestSchedule>

mysql> select * from g_test_schedule;
+-----------------+---------------------+-----------+--------------+------------------+-------------+--------------------+
| g_creation_time | g_modification_time | g_deleted | g_request_id | g_transaction_id | g_test_date | g_test_description |
+-----------------+---------------------+-----------+--------------+------------------+-------------+--------------------+
|      1314169240 |          1314169240 | False     |       275303 |           175743 |        NULL | NULL               |
|      1314169364 |          1314169364 | False     |       275305 |           175744 |        NULL | NULL               |
+-----------------+---------------------+-----------+--------------+------------------+-------------+--------------------+
2 rows in set (0.00 sec)

Problem: values on g_test_date and and g_test_description are NULL.


Not sure what I done wrong.
Thanks again.
Quang.




-----Original Message-----
From: gold-users-bounces at supercluster.org [mailto:gold-users-bounces at supercluster.org] On Behalf Of gold-users-request at supercluster.org
Sent: Tuesday, 23 August 2011 8:32 AM
To: gold-users at supercluster.org
Subject: gold-users Digest, Vol 54, Issue 3

Send gold-users mailing list submissions to
        gold-users at supercluster.org

To subscribe or unsubscribe via the World Wide Web, visit
        http://www.supercluster.org/mailman/listinfo/gold-users
or, via email, send a message with subject or body 'help' to
        gold-users-request at supercluster.org

You can reach the person managing the list at
        gold-users-owner at supercluster.org

When replying, please edit your Subject line so it is more specific
than "Re: Contents of gold-users digest..."


Today's Topics:

   1. Re: Creating a Gold Custom Object (Scott Jackson)
   2. Re: Creating a Gold Custom Object (Scott Jackson)
   3. Re: Creating a Gold Custom Object (Scott Jackson)


----------------------------------------------------------------------

Message: 1
Date: Mon, 22 Aug 2011 12:07:31 -0600 (MDT)
From: Scott Jackson <scottmo at adaptivecomputing.com>
Subject: Re: [gold-users] Creating a Gold Custom Object
To: Gold Users Mailing List <gold-users at supercluster.org>
Message-ID: <1004733398.32016.1314036451042.JavaMail.root at mail>
Content-Type: text/plain; charset="utf-8"

I think you will need to use quotes.



TestSchedule Create TestDate="2011-01-01" TestDescription=Testing

Scott

----- Original Message -----


From: "Quang Ho" <quang.ho at hp.com>
To: gold-users at supercluster.org
Sent: Tuesday, August 16, 2011 12:18:52 AM
Subject: [gold-users] Creating a Gold Custom Object




Hi,

I tried to create a custom object as below via goldsh



Object Create Name=TestSchedule Description=?Test Schedule?

Attribute Create Object =TestSchedule Name=TestDate DataType=TimeStamp

Attribute Create Object =TestSchedule Name=TestDescription DataType=String



Action Create Object=TestSchedule Name=Create Display=True Description Create

Action Create Object=TestSchedule Name=Query Display=True Description Query



When I tried to populate data into it,

TestSchedule Create TestDate=2011-01-01 TestDescription=Testing



It came back with:

TestDate TestDescription

----------- -------------------

2011 Testing

Successfully created 1 TestSchedule



The problem is it does not record a full date in database, it only stores the year in the TestDate field.



To check the usage



<Request action="Create">

<Object>TestSchedule</Object>

[<Set name="TestDate" [op="Assign (Assign)"]>YYYY-MM-DD[ hh:mm:ss]|-infinity|infinity|now</Set>]

?..

[<Option name="ShowHidden">True|False (False)</Option>]

[<Option name="ShowUsage">True|False (False)</Option>]

</Request>



Not sure what I did wrong.

Thanks in advance.






_______________________________________________
gold-users mailing list
gold-users at supercluster.org
http://www.supercluster.org/mailman/listinfo/gold-users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.supercluster.org/pipermail/gold-users/attachments/20110822/e9f44618/attachment-0001.html

------------------------------

Message: 2
Date: Mon, 22 Aug 2011 16:11:59 -0600 (MDT)
From: Scott Jackson <scottmo at adaptivecomputing.com>
Subject: Re: [gold-users] Creating a Gold Custom Object
To: Gold Users Mailing List <gold-users at supercluster.org>
Message-ID: <1083333908.33725.1314051119160.JavaMail.root at mail>
Content-Type: text/plain; charset="utf-8"

Ahh, OK, so Chi Hung and Jong Su and I looked into this further and we know what the issue is now.

goldsh is a low level prompt which simply takes a name-value pair format and serializes it into the XML Request, sends it over the wire, and then displays the response. The issue is that technically, the timestamps must be passed over the wire in epoch time format. So, technically what we are sending is:

<Request action="Create" actor="scottmo"><Object>TestSchedule</Object><Set name="TestTime">1293865200</Set><Set name="TestDescription">Testing</Set></Request></Body>

To do this, you should technically be building a goldsh request as follows:

gold> TestSchedule Create TestDate=1293865200 TestDescription=Testing
Successfully created 1 TestSchedule

Since the request is built up on the client side, which does not have access to the server which knows this field to be a timestamp, the goldsh interface cannot know unless you tell it that the field is a timestamp so that it can convert it to an epoch integer. Now, many of the examples in the documentation take advantage of a little trick I put into goldsh which is that if the name of the assignment ends in the word "Time", then we will take this as a timestamp and convert it. That is why if you had created the name of the attribute as TestTime instead of TestDate, things would have worked as expected, allowing you to enter time expressions instead of epoch times:

gold> Attribute Create Object=TestSchedule Name=TestTime DataType=TimeStamp
Successfully created 1 Attribute
gold> TestSchedule Create TestTime=2011-01-01 TestDescription=Testing
Successfully created 1 TestSchedule

Now, I have started considering the possibility of allowing a string format to be legal over the wire, but this means that I will have to check it on the server side and convert it to an epoch integer in the Gold::Proxy->prepareAssignments routine.

I tested this approach and it seems to work. I would just have to think about it some more to be sure it does not cause any problems or performance issues.

Alternatively, I could provide a syntax to decode the timestamp on the goldsh line:

TestSchedule Create TestDate=Timestamp(2011-01-01) TestDescription=Testing

or I could cheat a little more and do time conversions for all attributes that end in Date or Time.

If you are interested in a small local patch that would resolve this problem for you temporarily, you could patch your Proxy.pm with:

scottmo at mana:/software/gold-2.2$ diff -Nau lib/Gold/Proxy.pm /opt/gold-2.2/lib/Gold/Proxy.pm
--- lib/Gold/Proxy.pm 2011-07-26 13:32:33.911886963 -0600
+++ /opt/gold-2.2/lib/Gold/Proxy.pm 2011-08-22 15:44:39.581992562 -0600
@ -638,6 +634,12 @@
}
}

+ my $dataType = Gold::Cache->getAttributeProperty($object, $name, "DataType");
+ if ($dataType eq 'TimeStamp' && $value !~ /^\d+$/)
+ {
+ $value = toMFT($value);
+ }
+
# Add assignment to cooked request (after appropriate checking)
$self->addAssignment($request, \@cookedAssignments, $name, $value,
$op);

Thanks,

Scott

----- Original Message -----


From: "Scott Jackson" <scottmo at adaptivecomputing.com>
To: "Gold Users Mailing List" <gold-users at supercluster.org>
Sent: Monday, August 22, 2011 12:07:31 PM
Subject: Re: [gold-users] Creating a Gold Custom Object


I think you will need to use quotes.



TestSchedule Create TestDate="2011-01-01" TestDescription=Testing

Scott

----- Original Message -----


From: "Quang Ho" <quang.ho at hp.com>
To: gold-users at supercluster.org
Sent: Tuesday, August 16, 2011 12:18:52 AM
Subject: [gold-users] Creating a Gold Custom Object




Hi,

I tried to create a custom object as below via goldsh



Object Create Name=TestSchedule Description=?Test Schedule?

Attribute Create Object =TestSchedule Name=TestDate DataType=TimeStamp

Attribute Create Object =TestSchedule Name=TestDescription DataType=String



Action Create Object=TestSchedule Name=Create Display=True Description Create

Action Create Object=TestSchedule Name=Query Display=True Description Query



When I tried to populate data into it,

TestSchedule Create TestDate=2011-01-01 TestDescription=Testing



It came back with:

TestDate TestDescription

----------- -------------------

2011 Testing

Successfully created 1 TestSchedule



The problem is it does not record a full date in database, it only stores the year in the TestDate field.



To check the usage



<Request action="Create">

<Object>TestSchedule</Object>

[<Set name="TestDate" [op="Assign (Assign)"]>YYYY-MM-DD[ hh:mm:ss]|-infinity|infinity|now</Set>]

?..

[<Option name="ShowHidden">True|False (False)</Option>]

[<Option name="ShowUsage">True|False (False)</Option>]

</Request>



Not sure what I did wrong.

Thanks in advance.






_______________________________________________
gold-users mailing list
gold-users at supercluster.org
http://www.supercluster.org/mailman/listinfo/gold-users


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.supercluster.org/pipermail/gold-users/attachments/20110822/2452cd6f/attachment-0001.html

------------------------------

Message: 3
Date: Mon, 22 Aug 2011 16:34:36 -0600 (MDT)
From: Scott Jackson <scottmo at adaptivecomputing.com>
Subject: Re: [gold-users] Creating a Gold Custom Object
To: Gold Users Mailing List <gold-users at supercluster.org>
Message-ID: <265161383.33863.1314052476759.JavaMail.root at mail>
Content-Type: text/plain; charset="utf-8"

OK,

I decided to make that a permanent change to Gold. Let me know if you want me to upload a new distribution of gold.

Thanks,

Scott

$ svn diff -c 361
Index: configure.ac
===================================================================
--- configure.ac (revision 360)
+++ configure.ac (revision 361)
@@ -2,7 +2,7 @@
# Process this file with autoconf to produce a configure script.

AC_PREREQ(2.57)
-AC_INIT(Gold, [2.2.0.3], [gold-support at adaptivecomputing.com])
+AC_INIT(Gold, [2.2.0.4], [gold-support at adaptivecomputing.com])
AC_CONFIG_SRCDIR([src/goldd.pl.in])
#AC_CONFIG_HEADER([config.h])

Index: lib/Gold/Proxy.pm
===================================================================
--- lib/Gold/Proxy.pm (revision 360)
+++ lib/Gold/Proxy.pm (revision 361)
@@ -716,6 +716,14 @@
"$object $name is a primary key and cannot be modified");
}

+ # Convert timestamp expressions to epoch integers
+ my $dataType =
+ Gold::Cache->getAttributeProperty($object, $name, "DataType");
+ if ($dataType eq "TimeStamp" && $value !~ /^\d+$/)
+ {
+ $value = toMFT($value);
+ }
+
# If this has values, verify that the value exists
my $values = Gold::Cache->getAttributeProperty($object, $name, "Values");
if (defined $values && $value ne "NULL")
Index: CHANGES
===================================================================
--- CHANGES (revision 360)
+++ CHANGES (revision 361)
@@ -3,6 +3,9 @@
Fix Release 2.2.0.4

Modify goldsh to accept lowercase attribute names.
+ Gold::Proxy->prepare now converts human readable timestamp assignment values
+ to epoch integers for you so that clients (goldsh) do not need to do this.
+

Fix Release 2.2.0.3



----- Original Message -----


From: "Scott Jackson" <scottmo at adaptivecomputing.com>
To: "Gold Users Mailing List" <gold-users at supercluster.org>
Sent: Monday, August 22, 2011 4:11:59 PM
Subject: Re: [gold-users] Creating a Gold Custom Object


Ahh, OK, so Chi Hung and Jong Su and I looked into this further and we know what the issue is now.

goldsh is a low level prompt which simply takes a name-value pair format and serializes it into the XML Request, sends it over the wire, and then displays the response. The issue is that technically, the timestamps must be passed over the wire in epoch time format. So, technically what we are sending is:

<Request action="Create" actor="scottmo"><Object>TestSchedule</Object><Set name="TestTime">1293865200</Set><Set name="TestDescription">Testing</Set></Request></Body>

To do this, you should technically be building a goldsh request as follows:

gold> TestSchedule Create TestDate=1293865200 TestDescription=Testing
Successfully created 1 TestSchedule

Since the request is built up on the client side, which does not have access to the server which knows this field to be a timestamp, the goldsh interface cannot know unless you tell it that the field is a timestamp so that it can convert it to an epoch integer. Now, many of the examples in the documentation take advantage of a little trick I put into goldsh which is that if the name of the assignment ends in the word "Time", then we will take this as a timestamp and convert it. That is why if you had created the name of the attribute as TestTime instead of TestDate, things would have worked as expected, allowing you to enter time expressions instead of epoch times:

gold> Attribute Create Object=TestSchedule Name=TestTime DataType=TimeStamp
Successfully created 1 Attribute
gold> TestSchedule Create TestTime=2011-01-01 TestDescription=Testing
Successfully created 1 TestSchedule

Now, I have started considering the possibility of allowing a string format to be legal over the wire, but this means that I will have to check it on the server side and convert it to an epoch integer in the Gold::Proxy->prepareAssignments routine.

I tested this approach and it seems to work. I would just have to think about it some more to be sure it does not cause any problems or performance issues.

Alternatively, I could provide a syntax to decode the timestamp on the goldsh line:

TestSchedule Create TestDate=Timestamp(2011-01-01) TestDescription=Testing

or I could cheat a little more and do time conversions for all attributes that end in Date or Time.

If you are interested in a small local patch that would resolve this problem for you temporarily, you could patch your Proxy.pm with:

scottmo at mana:/software/gold-2.2$ diff -Nau lib/Gold/Proxy.pm /opt/gold-2.2/lib/Gold/Proxy.pm
--- lib/Gold/Proxy.pm 2011-07-26 13:32:33.911886963 -0600
+++ /opt/gold-2.2/lib/Gold/Proxy.pm 2011-08-22 15:44:39.581992562 -0600
@ -638,6 +634,12 @@
}
}

+ my $dataType = Gold::Cache->getAttributeProperty($object, $name, "DataType");
+ if ($dataType eq 'TimeStamp' && $value !~ /^\d+$/)
+ {
+ $value = toMFT($value);
+ }
+
# Add assignment to cooked request (after appropriate checking)
$self->addAssignment($request, \@cookedAssignments, $name, $value,
$op);

Thanks,

Scott

----- Original Message -----


From: "Scott Jackson" <scottmo at adaptivecomputing.com>
To: "Gold Users Mailing List" <gold-users at supercluster.org>
Sent: Monday, August 22, 2011 12:07:31 PM
Subject: Re: [gold-users] Creating a Gold Custom Object


I think you will need to use quotes.



TestSchedule Create TestDate="2011-01-01" TestDescription=Testing

Scott

----- Original Message -----


From: "Quang Ho" <quang.ho at hp.com>
To: gold-users at supercluster.org
Sent: Tuesday, August 16, 2011 12:18:52 AM
Subject: [gold-users] Creating a Gold Custom Object




Hi,

I tried to create a custom object as below via goldsh



Object Create Name=TestSchedule Description=?Test Schedule?

Attribute Create Object =TestSchedule Name=TestDate DataType=TimeStamp

Attribute Create Object =TestSchedule Name=TestDescription DataType=String



Action Create Object=TestSchedule Name=Create Display=True Description Create

Action Create Object=TestSchedule Name=Query Display=True Description Query



When I tried to populate data into it,

TestSchedule Create TestDate=2011-01-01 TestDescription=Testing



It came back with:

TestDate TestDescription

----------- -------------------

2011 Testing

Successfully created 1 TestSchedule



The problem is it does not record a full date in database, it only stores the year in the TestDate field.



To check the usage



<Request action="Create">

<Object>TestSchedule</Object>

[<Set name="TestDate" [op="Assign (Assign)"]>YYYY-MM-DD[ hh:mm:ss]|-infinity|infinity|now</Set>]

?..

[<Option name="ShowHidden">True|False (False)</Option>]

[<Option name="ShowUsage">True|False (False)</Option>]

</Request>



Not sure what I did wrong.

Thanks in advance.






_______________________________________________
gold-users mailing list
gold-users at supercluster.org
http://www.supercluster.org/mailman/listinfo/gold-users



-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.supercluster.org/pipermail/gold-users/attachments/20110822/efcb99a5/attachment.html

------------------------------

_______________________________________________
gold-users mailing list
gold-users at supercluster.org
http://www.supercluster.org/mailman/listinfo/gold-users


End of gold-users Digest, Vol 54, Issue 3
*****************************************


More information about the gold-users mailing list