Multi-tenant API: Issue creating Area

Posted by bronco on 10-Jun-2013 02:33

Hi,

I'm running into an issue when trying to create a Area via the API. What happens is that once I do the CreateArea statement I get an error that it can't find my database in the session working directory, which is absolutly correct since it's not there.

What am I doing wrong here? (Ps the service variable has already been initialized

  method private void createTenant(tenantName as character): /* , domainName as character): */

   

    define variable areas      as IAreaSet    no-undo.

    define variable dataArea   as IArea       no-undo.

    define variable success    as logical     no-undo.

    define variable newExtent  as IExtent     no-undo.

   

   

    areas = service:GetAreas().

    dataArea = service:NewArea(tenantName + "-data").

    dataArea:ClusterSize = 64.

    dataArea:RecordsPerBlock = 32.

   

    newExtent = service:NewExtent().

    newExtent:Path = ".".

    newExtent:IsFixed = true.

    newExtent:Size = 1000000.

   

    dataArea:Extents:Add(newExtent).

       

    service:CreateArea(dataArea).

   

    catch err1 as Progress.Lang.Error :

    message "ERROR:" err1:GetMessage(1) view-as alert-box.

    end catch.

   

  end method.

end class.

All Replies

Posted by bronco on 10-Jun-2013 02:39

PS. there's some clutter in the code, namely the areas variable, which is a remnant of attemps to get it to work...

Posted by bronco on 10-Jun-2013 04:48

PS2 (I keep on replying to my own post): When setting the path to the db directory I still get the same error.

Posted by Admin on 10-Jun-2013 04:58

What is the exact error message and stack trace?

Posted by bronco on 10-Jun-2013 05:04

The error is:

** Cannot find or open file D:\arch\oera\src\multiten.db, errno = 2. (43).

Which is indeed not where my db is located (but that is my working directory).

The stack trace is:

CheckStatus OpenEdge.DataAdmin.ServerCommand.ProstrctAddOnlineCommand at line 96  (OpenEdge/DataAdmin/ServerCommand/ProstrctAddOnlineCommand.r)

RunCommand OpenEdge.DataAdmin.ServerCommand.ProCommand at line 159  (OpenEdge/DataAdmin/ServerCommand/ProCommand.r)

Execute OpenEdge.DataAdmin.ServerCommand.ProCommand at line 63  (OpenEdge/DataAdmin/ServerCommand/ProCommand.r)

ExecuteProstruct OpenEdge.DataAdmin.DataSource.ExtentDataSource at line 110  (OpenEdge/DataAdmin/DataSource/ExtentDataSource.r)

Save OpenEdge.DataAdmin.DataSource.ExtentDataSource at line 95  (OpenEdge/DataAdmin/DataSource/ExtentDataSource.r)

SaveData OpenEdge.DataAdmin.DataAccess.AreaData at line 63  (OpenEdge/DataAdmin/DataAccess/AreaData.r)

SaveData OpenEdge.DataAdmin.Server.DataService at line 175  (OpenEdge/DataAdmin/Server/DataService.r)

SaveData OpenEdge.DataAdmin.Binding.ServiceAdapter at line 146  (OpenEdge/DataAdmin/Binding/ServiceAdapter.r)

SaveData OpenEdge.DataAdmin.DataAdminService at line 1108  (OpenEdge/DataAdmin/DataAdminService.r)

CreateElement OpenEdge.DataAdmin.DataAdminService at line 246  (OpenEdge/DataAdmin/DataAdminService.r)

CreateArea OpenEdge.DataAdmin.DataAdminService at line 165  (OpenEdge/DataAdmin/DataAdminService.r)

createTenant oera.service.MultiTenancyManager at line 61  (D:\arch\oera\src\oera\service\MultiTenancyManager.cls)

CompanyModified oera.service.MultiTenancyManager at line 29  (D:\arch\oera\src\oera\service\MultiTenancyManager.cls)

broadCastDbActions sys.server.beCompany at line 88  (D:\arch\oera\src\ztestapp\sys\server\beCompany.cls)

StoreData sys.server.beCompany at line 76  (D:\arch\oera\src\ztestapp\sys\server\beCompany.cls)

D:\arch\oera\src\ztests\sys\server\test-becompany-storedata.p at line 70  (D:\arch\oera\src\ztests\sys\server\test-becompany-storedata.p)

Oh, I'm running OE11.2.1

Posted by Håvard Danielsen on 10-Jun-2013 11:13

PS2 (I keep on replying to my own post): When setting the path to the db directory I still get the same error.

You replied to my question also... I do not remember the exact expected behavior of the Path, but I suspect "." assumes current working directory.

Please report a bug for the fact that setting the correct path does not work.

Have this ever worked for you?

Can you test it in a session that has the same current (startup) directory as the database?

Posted by bronco on 11-Jun-2013 01:58

Hello Havard,

To answer your questions:

From a ABL perspective "." represeting the working directory seems logical. In this case however, it is more logical that "." is the location of the db file, otherwise you have to somehow insert some knowledge in your application about the physical whereabouts of the database (on another server). IMHO that's not desirable, would you agree?

I will file a bugreport for the absolute Path setting not working correctly.

After copying the database to the working directory of the session it works fine. Although it works this way I do not consider this a working solution.

This is all new, so no clue if it ever worked.

Thanks

Posted by Håvard Danielsen on 11-Jun-2013 09:39

From a ABL perspective "." represeting the working directory seems logical. In this case however, it is more logical that "." is the location of the db file, otherwise you have to somehow insert some knowledge in your application about the physical whereabouts of the database (on another server). IMHO that's not desirable, would you agree?

I agree on your last sentence, but the "." means current in the ABL world and is also interpreted as such in the .st file that is used to generate the areas.  But your requirement is actually resolved, as the default is to use the database path. This is specified by a blank Path and the default value of the property is blank.

So your code should work as expected if you do not specify the Path at all (or set it to "").  Note that I did not test this and that the bug you found in theory also may affect this behavior.

Posted by Tim Kuehn on 14-Jun-2013 01:02

I had a similar problem, and solved it by extracting the location of the db from the connection, like so:

    oDbService                  = NEW OpenEdge.DataAdmin.DataAdminService(LDBNAME(1))
    chDbPath                    = SUBSTRING(PDBNAME(LDBNAME(1)), 1, LENGTH(PDBNAME(LDBNAME(1))) - LENGTH(LDBNAME(1)))

use chDbPath instead of "." and your code "should" work.

Posted by Håvard Danielsen on 14-Jun-2013 10:25

I had a similar problem, and solved it by extracting the location of the db from the connection, like so:

    oDbService                  = NEW OpenEdge.DataAdmin.DataAdminService(LDBNAME(1))
    chDbPath                    = SUBSTRING(PDBNAME(LDBNAME(1)), 1, LENGTH(PDBNAME(LDBNAME(1))) - LENGTH(LDBNAME(1)))

use chDbPath instead of "." and your code "should" work.

That is interesting. As far as I can understand, this is the equivalent of what Bronco was not able to make work, except that he hardcoded the database path. 

Note that you should not need to do this if you want to use the database path. The default behavior (with Path="") is to use the database directory.  

Posted by Tim Kuehn on 14-Jun-2013 12:30

I'm not sure what the reason is - I'm attaching the code I used to this message for others to check out.

Posted by Tim Kuehn on 14-Jun-2013 12:36

I'm running PDS 11.1 underW7, and these all worked for me:

  • Set chDbPath    = "D:\tmp\db"
  • disable the part of the assign that sets oExtent:path, so it's not set
  • change the "Assign" to point to a different dir under chDbPath (ie oExtent:path = chDbPath   + "/new")
  • use "." for a path

Which is puzzling consdiering Bronco's experience.

Posted by Håvard Danielsen on 14-Jun-2013 14:09

I'm running PDS 11.1 underW7, and these all worked for me:

  • Set chDbPath    = "D:\tmp\db"
  • disable the part of the assign that sets oExtent:path, so it's not set
  • change the "Assign" to point to a different dir under chDbPath (ie oExtent:path = chDbPath   + "/new")
  • use "." for a path

Thanks a lot for this information. A confirmation that it works for others is worth a lot more than my own "works for me".

Which is puzzling consdiering Bronco's experience.

We would need more information to figure it out. I'm sure Support will get the missing information.

Posted by bronco on 16-Jun-2013 13:24

I've logged a call with support (00245923) ion tuesdat but haven't heard from it yet.

Posted by bronco on 16-Jun-2013 13:51

I've logged a call with support (00245923) on tuesday but haven't heard from it yet.

Meanwhile I get another error, namely:

Extent for area tenant3-data cannot be created with default path because the database info is not known. Specify a valid directory name or use period to specify the current directory.

I get this when I leave the Path blank (but set) and the database is in the working directory. Setting the Path to either "." or the working path works fine.

@Tim: I guess the version (11.2.1) makes the difference.

I'll have to wait for support. Thanks

PS. Ctrl-enter send the message (too soon) on my machine, hence replying twice.

Posted by Håvard Danielsen on 17-Jun-2013 17:30

I've logged a call with support (00245923) on tuesday but haven't heard from it yet.

Meanwhile I get another error, namely:

Extent for area tenant3-data cannot be created with default path because the database info is not known. Specify a valid directory name or use period to specify the current directory.

I get this when I leave the Path blank (but set) and the database is in the working directory. Setting the Path to either "." or the working path works fine.

@Tim: I guess the version (11.2.1) makes the difference.

I'll have to wait for support. Thanks

PS. Ctrl-enter send the message (too soon) on my machine, hence replying twice.

I doubt 11.2.1 makes any difference. This error is thrown when the physical name of the database is not known (as in pdbname("dictdb")), so your problems seem to be caused by a remote connection.

Posted by Tim Kuehn on 18-Jun-2013 15:27

as in client-server?

All my testing was done self-serve direct connect.

This thread is closed