betweenGo

Author Archive

Changing VirtualBox’s Disk Image Sizes

by on Jul.23, 2011, under Mac

Teacup's Revenge | Flickr

Teacup’s Revenge by Earl-Wilkerson

I was running out of room in my Virtual Box Windows 7 disk.  Windows was reporting used space of 18.6 GB and free space of 1.22 GB.  My Mac was reporting that my disk image was using up 21.39 GB.

Compacting

On your Windows Guest:

  1. Run Disk Cleanup.
  2. Run Disk Defragmenter.
  3. Download SDelete and use it to zero out free space. I put sdelete in C:\Windows\System32 and then ran it like this from the command prompt.
    C:\> sdelete -c c:/

  4. Shutdown Windows.

On your Mac Host:

  1. Run VBoxManage from the Terminal to compact the disk image.
    $ VBoxManage modifyhd Windows.vdi --compact

Sad Story

I first tried shrinking the disk image to see if that would free up room using the instructions above which were based on the article How To Shrink Your Virtualbox VM And Free Up Space For Your Hard Disk.

After doing this Windows reported used space of 18.8 GB and free space of 1.03 GB.  In other words no difference. Sad smile  But on the Mac the disk image was now only using up 20.51 GB.

Resizing

On your Windows Guest:

  1. Shutdown Windows.

On your Mac Host:

  1. Run VBoxManage from the Terminal to resize the disk image. This is how I did it.
    $ VBoxManage modifyhd Windows.vdi --resize N

On your Windows Guest:

  1. Restart Windows.
  2. Use diskpart to resize the C: drive to use the new space.

Happy Story

Realizing that compacting did not work I shut down again and this time increased the size of the disk image by 10 GB from 20 GB to 30 GB (N = 30720).

VirtualBox showed in its settings that the disk image size was now 30 GB.  But Windows still reported used space of 18.8 GB and free space of 1.03 GB.  Again no difference. Sad smile  And on the Mac the disk image was still the same but that was to be expected.

Back to Google which led me to Windows’ brilliant tool diskpart.

C:\>diskpart

Microsoft DiskPart version 6.1.7600
Copyright (C) 1999-2008 Microsoft Corporation.
On computer: WIN-7-IMAC-POOP

DISKPART> list volume

  Volume ###  Ltr  Label        Fs     Type        Size     Status     Info
  ----------  ---  -----------  -----  ----------  -------  ---------  --------
  Volume 0     D   VBOXADDITIO  CDFS   CD-ROM        38 MB  Healthy
  Volume 1         System Rese  NTFS   Partition    100 MB  Healthy    System
  Volume 2     C                NTFS   Partition     19 GB  Healthy    Boot

DISKPART> select volume 2

Volume 2 is the selected volume.

DISKPART> extend size=10240

DiskPart successfully extended the volume.

Windows now reported free space of 11.0 GB.Open-mouthed smile

End Note

I originally tried resizing the disk by specifying the size of how much I wanted the disk increased, i.e. 10 GB or N=10240.

$ VBoxManage modifyhd Library/VirtualBox/HardDisks/Windows\ 7.vdi --resize 10240

This failed with the strange error:

Progress state: VBOX_E_NOT_SUPPORTED
VBoxManage: error: Resize hard disk operation for this format is not implemented yet!

Fortunately I found out in one of the VirtualBox forums that this happened because I gave the wrong argument to resize.  Too bad the error message wasn’t a little more helpful. Smile

Share
1 Comment :, more...

Adding a New Link to a Commerce Pipeline

by on Jun.22, 2011, under Commerce

Only as strong as the weakest link. Part 2 | Flickr

Only as strong as the weakest link. Part 2 by David’n'Sheila

To add new links to a commerce pipeline you need to override the default definition for the appropriate commerce pipeline.  Commerce pipelines are defined in XML so you use ATG’s XML combining feature to accomplish this.

For example if you want to add a new link to the ProcessOrder chain in the /atg/commerce/commercepipeline.xml you would create the following commercepipeline.xml in your local config.

<pipelinemanager>
  <pipelinechain name="processOrder" xml-combine="append">
    <pipelinelink transaction="TX_MANDATORY" name="authorizePayment" xml-combine="replace">
      <processor jndi="/atg/commerce/order/processor/AuthorizePayment" />
      <transition returnvalue="1" link="updateInventory" />
    </pipelinelink>
    <pipelinelink name="updateInventory" transaction="TX_MANDATORY">
      <processor jndi="/betweengo/commerce/inventory/processor/ProcUpdateInventory" />
      <transition returnvalue="1" link="updateGiftRepository" />
    </pipelinelink>
</pipelinemanager>

In this example we added the new updateInventory link which is inserted between the authorizePayment and updateGiftRepository links.

Share
Leave a Comment :, more...

Create Tablespaces in Oracle

by on Mar.21, 2011, under Oracle

Zero Table | Flickr

Zero Table by CommandZed

Previously I posted about how to import and create users in Oracle and in those examples I used the tablespaces provided by Oracle, users and temp.  But often you will want to create your own tablespace and use that one as the default tablespace for your users.

Here is an example of how to create a tablespace with the name foo of size 1 GB. Note that it is created in /Users/oracle/oradata/orcl which is the default folder for dataspaces on Mac OS X.

create tablespace
foo
datafile '/Users/oracle/oradata/orcl/foo.dbf'
size 1g;

Here is an example of how to create the same tablespace except now you are allowing it to grow bigger in 100 MB increments up to a maximum of 2 GB.  If you don’t specify the maximum it will grow unlimited.

create tablespace
foo
datafile '/Users/oracle/oradata/orcl/foo.dbf'
size 1g
autoextend on
next 100m
maxsize 2g;

If your tablespace is not big enough you can resize it using syntax like this.

alter database
datafile '/Users/oracle/oradata/orcl/foo.dbf'
resize 10g;

To see how big your tablespaces are you can use this query.

SELECT /* + RULE */  df.tablespace_name "Tablespace",
       df.bytes / (1024 * 1024) "Size (MB)",
       SUM(fs.bytes) / (1024 * 1024) "Free (MB)",
       Nvl(Round(SUM(fs.bytes) * 100 / df.bytes),1) "% Free",
       Round((df.bytes - SUM(fs.bytes)) * 100 / df.bytes) "% Used"
  FROM dba_free_space fs,
       (SELECT tablespace_name,SUM(bytes) bytes
          FROM dba_data_files
         GROUP BY tablespace_name) df
 WHERE fs.tablespace_name (+)  = df.tablespace_name
 GROUP BY df.tablespace_name,df.bytes
UNION ALL
SELECT /* + RULE */ df.tablespace_name tspace,
       fs.bytes / (1024 * 1024),
       SUM(df.bytes_free) / (1024 * 1024),
       Nvl(Round((SUM(fs.bytes) - df.bytes_used) * 100 / fs.bytes), 1),
       Round((SUM(fs.bytes) - df.bytes_free) * 100 / fs.bytes)
  FROM dba_temp_files fs,
       (SELECT tablespace_name,bytes_free,bytes_used
          FROM v$temp_space_header
         GROUP BY tablespace_name,bytes_free,bytes_used) df
 WHERE fs.tablespace_name (+)  = df.tablespace_name
 GROUP BY df.tablespace_name,fs.bytes,df.bytes_free,df.bytes_used
 ORDER BY 4 DESC;

Here is an example of how to drop a tablespace including its contents and datafiles.

drop tablespace foo including contents and datafiles

For further reading please see Oracle create tablespace & alter tablespace syntax, Tablespace – Oracle FAQ and How enlarge or decrease the size of an Oracle Tablespace.

Share
Leave a Comment : more...

SQL Delete in One Table Based on Values in Another Table

by on Mar.14, 2011, under Oracle

Growing | Flickr

Growing by Simon Peckham

Delete From One Table Whose Values Don’t Appear in Another Table

Sometimes you will find that you have items in a table whose values reference items in another table that no longer exist.  For example in ATG you may have orders that reference profiles that no longer exist.  This could happen if an order is for an anonymous profile that was deleted.

Here is an example of how to delete items in a table whose values reference items in another table that no longer exist, in this case ATG orders whose profiles no longer exist.

DELETE FROM dcspp_order
WHERE profile_id
NOT IN
(
  SELECT id
  FROM dps_user
);

This example does not actually work because of the dependencies on the dcspp_order table so please don’t try it. Smile

Delete From One Table Based on Values in Another Table

Sometimes you want to delete items in one tables based on values in another table.  You can do this similarly to the previous case.

DELETE FROM dcspp_order
WHERE profile_id
IN
(
  SELECT id
  FROM dps_user
  WHERE id LIKE '6%'
);

This example also does not actually work because of the dependencies on the dcspp_order table so please don’t try it. Smile

For further reading please see How to delete records from a SQL Server database and SQL Delete Rows Based on Another Table.

Share
Leave a Comment :, , more...

Specifying the Calculator per Promotion

by on Mar.07, 2011, under Commerce

calculator on Flickr

(Photo: calculator by ansik)

ATG’s documentation, as far as I can’t tell, does not document how to specify the calculator for a promotion.  Promotion’s have a repository property called pricingCalculatorService.  In the ACC you won’t see it by default but you will see it if you show expert-level information.  Also you can see it configured in the Promotion repository (/atg/commerce/pricing/Promotions).

Having a repository property for each promotion allows you to specify different calculators for different promotions.  But typically you will probably specify the same one for the same class of promotion, e.g. /betweengo/commerce/pricing/calculators/ItemDiscountCalculator.

Share
Leave a Comment more...

Incorporated

by on Mar.03, 2011, under Consulting

Bursting | FlickrYesterday I incorporated.  My business is now officially betweenGo LLC.

Special thanks goes to my lawyer, Allen M. Lee, and accountant, Leyla Hanson.  I highly recommend both.

Now I just need to figure out payroll, accounting, etc. Smile

Share
Leave a Comment : more...

VirtualBox Unable to Run Two Instances

by on Feb.28, 2011, under Mac

Double Bows by Nicholas_T

I have been using VirtualBox for awhile and have been pretty pleased with it considering it’s a free solution.  I blogged about wanting to try it over two years ago.

Today I started up Windows 7 on my iMac.  Then I tried to start up Windows XP but got this error.

Failed to open a session for the virtual machine Windows XP Pro Media Center.

PIIX3 cannot attach drive to the Secondary Master
(VERR_SHARING_VOILATION).

Unknown error creating VM (VERR_SHARING_VIOLATION).

Fortunately Google came to the rescue and led me to this article in the VirtualBox forums, Can’t run multiple Instances on OSX Leapord.  Once I unmounted the DVD drive in Windows 7 (Devices –> CD/DVD Devices) I was able to start Windows XP.

Share
Leave a Comment : more...

Programming Secure FTP in Java

by on Feb.21, 2011, under Java SE

Often server applications need to upload or download files using FTP.  But in this age of increasing security awareness vendors are now asking this be done using SFTP (Secure FTP).

Fortunately this is not difficult using the JSch (Java Secure Channel) library.  The downloadable JSch archive includes numerous examples.  I used the Sftp.java to implement SFTP for my server application.

Starting a connection to an SFTP server using JSch is somewhat simple.

JSch jsch = new JSch();

// start session
session = jsch.getSession(username, host);

// specify our own user info to accept secure connection to FTP server
UserInfo ui = new MyUserInfo(host);
session.setUserInfo(ui);

// set password
session.setPassword(password);

// connect
session.connect();

// get SFTP channel
Channel channel = session.openChannel("sftp");
channel.connect();
schannel = (ChannelSftp) channel;

The trick is getting past confirmation of the authenticity of the host. I do this my creating my own UserInfo implementation, MyUserInfo, which knows about the host I am connecting to. The only method I implement is the promptYesNo method which simply checks if the message is asking about the host I want to connect to.

protected MyUserInfo(final String pKnownHost) {
    this.mKnownHost = pKnownHost;
}

@Override
public boolean promptYesNo(final String pMessage) {
    // message looks like this "The authenticity of host 'foo.com' can't be established..."
    final int start = pMessage.indexOf("'") + 1;
    final int end = pMessage.indexOf("'", start);
    final String host = pMessage.substring(start, end);

    // is the host a known host?
    return this.mKnownHost.equals(host);
}

Now uploading is trivial.

schannel.put(src, dest);

For further reading please see Java: What is the best way to SFTP a file from a server.

Share
1 Comment :, more...

Configuring JBoss for HTTPS

by on Feb.16, 2011, under JBoss

Keys 1 by ~Brenda-Starr~

This is how I configured JBoss to handle HTTPS requests for secure ATG applications.

  1. Create the keystore and private key.
    $ cd /opt/jboss/jboss-eap-4.3/jboss-as/server/atg/conf
    $ keytool -genkey -alias jbosskey -keyalg RSA -keystore server.keystore
  2. Generate and store the certificate.
    $ keytool -export -alias jbosskey -file server.crt -keystore server.keystore
    $ keytool -import -alias jbosscert -file server.crt -keystore server.keystore
  3. Enable HTTPS.
    $ vi /opt/jboss/jboss-eap-4.3/jboss-as/server/atg/deploy/jboss-web.deployer/server.xml

    Uncomment SSL HTTP/1.1 Connector section and edit. For example:

        <Connector port="8443" address="${jboss.bind.address}"
                   protocol="HTTP/1.1" SSLEnabled="true"
                   maxThreads="150" scheme="https" secure="true"
                   clientAuth="false" sslProtocol="TLS"
                   keystoreFile="${jboss.server.home.dir}/conf/server.keystore"
                   keystorePass="letmein" />
  4. Start JBoss with keystore specified. On UNIX you can do this by updating run.conf. For example:
    JAVA_OPTS="-Xms128m -Xmx512m -XX:MaxPermSize=128m -Djavax.net.ssl.trustStore=/opt/jboss/jboss-eap-4.3/jboss-as/server/atg/conf/server.keystore -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000 -Dsun.lang.ClassLoader.allowArraySyntax=true"

Note that if you are using service bindings (i.e. uncommented service bindings section of conf/jboss-service.xml) then the bindings in the XML configuration file (e.g. sample-bindings.xml) will take precedence. In this case the secure port becomes 8543.

For further reading please see HOWTO Configure JBoss for HTTPS.

Share
Leave a Comment :, more...

Bootstrapping is the Rage

by on Jan.24, 2011, under Miscellaneous

Web startups boot strapping themselves are all the rage.  Every few weeks someone approaches me with a new idea.  The implementation plans for the venture are almost always identical.

  • web application
  • open source framework, usually Ruby on Rails, sometimes PHP
  • free database, almost always MySQL
  • cloud hosting
  • small group of guys, typically people who have made money at a previous venture
  • no salaries, just equity

Inspirations for these companies are places such 37signals, Wufoo, Plentyoffish and World of Goo.

I enjoy hearing the ideas and almost joined one venture.  But in the end none have been compelling enough for me to risk 6 to 12 months of income.  Hopefully I’ll think of one on my own. :-)

Share
Leave a Comment :, , , more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!