Nova postagem

検索

Pergunta
· Out. 10, 2024

How to Switch Namespaces and Access %SYS Namespace in an OpenAPI-Generated Classmethod?

Hello everyone,

I'm working with a class generated by OpenAPI in InterSystems IRIS, specifically impl.cls. In one of the classmethods of this class, I need to switch to the %SYS namespace to access system-level functionalities and then switch back to the original namespace.

I tried using the following commands:

new $namespace
set $namespace = “%SYS”

However, these give an error when executed. Is there a proper way to change namespaces programmatically within a classmethod and gain access to the %SYS namespace? Any best practices or example code snippets would be greatly appreciated!

Thank you!

5 Comments
Discussão (5)3
Entre ou crie uma conta para continuar
Anúncio
· Out. 10, 2024

[Video] Creating Virtual Models with Adaptive Analytics

Hi, Community!

Want to use your data to make better business decisions? Creating virtual models can help! See how:

Creating Virtual Models with InterSystems IRIS® Adaptive Analytics

In this video, you will learn:

  • How to quickly and easily create virtual data models
  • How the built-in AI of Adaptive Analytics improves your query speed

Continue learning with InterSystems IRIS Adaptive Analytics Essentials (online course, 2h).

Discussão (0)1
Entre ou crie uma conta para continuar
Pergunta
· Out. 10, 2024

Simple Way To Compare Streams

Is there a simple way to compare Stream data between two objects?

We have used $ZCRC to create a checksum and that seems to be work.

We have also read each line of the streams and compared them and that seems to work too.

We just think there has to be a simpler way than looping through all the lines of the stream.

Any suggestions would be appreciated.

7 Comments
Discussão (7)3
Entre ou crie uma conta para continuar
Artigo
· Out. 10, 2024 2min de leitura

Script de Freeze em servidores espelhados

Olá comunidade!

Eu trago aqui uma dica para poupar algumas horas do seu dia. A documentação InterSystems especifica muito bem como criar um script de freeze para as instâncias, mas não traz exemplos em instâncias espelhadas, onde queremos deixar o script automático, mas só rodar efetivamente na instância primária.

Primeiro, vamos criar uma classe abstrata no namespace %SYS com métodos que verificam se a instância é primária e, caso positivo, executam o freeze.

Class User.custom.FreezeThaw.Script [ Abstract ]
{

ClassMethod FreezeIfPrimary() As %Status
{
    Set tSC = $$$OK
    
    Try
    {
        If ##class(%SYSTEM.Mirror).IsPrimary()
        {
            Set tSC = ##class(Backup.General).ExternalFreeze()
        }
    }
    Catch Exception
    {
        Set tSC = Exception.AsStatus()
    }
    
    Quit tSC
}
}

Agora, escrevemos em um arquivo o script para congelar se for primária. Vou deixar esse arquivo no caminho /opt/script/, onde será criado um log:

#!/bin/bash
# variables used for returning the status
success=0
error=1
warning=2
status=$success
log_path="/opt/script/freezescript.log"
echo "`date` Logs:\n" >> $log_path
instance="IRISDB02"

# IRIS
iris session $instance -U%SYS "##Class(User.custom.FreezeThaw.Script).FreezeIfPrimary()"
status=$?
if [ $status -eq 0 ]; then
	echo "$instance IS FROZEN"
        printf  "$instance IS FROZEN\n" >> $log_path
else
        echo "$instance FREEZE FAILED"
        printf  "$instance FREEZE FAILED\n" >> $log_path
       	status=$error
        iris session $instance -U%SYS "##Class(User.custom.FreezeThaw.Script).ThawIfPrimary()" >> $log_path
fi

Finalmente, podemos escrever o método de descongelamento

ClassMethod ThawIfPrimary() As %Status
{
    Set tSC = $$$OK
    
    Try
    {
        If ##class(%SYSTEM.Mirror).IsPrimary()
        {
            Set tSC = ##class(Backup.General).ExternalThaw()
        }
    }
    Catch Exception
    {
        Set tSC = Exception.AsStatus()
    }
    
    Quit tSC
}

E é claro, no mesmo caminho, criamos um script para o descongelamento:

#!/bin/bash
# variables used for returning the status
success=0
error=1
warning=2
status=$success
log_path="/opt/script/freezescript.log"
instance="IRISDB02"

# IRIS
iris session $instance -U%SYS "##Class(User.custom.FreezeThaw.Script).ThawIfPrimary()" >> $log_path
status=$?
if [ $status -eq 0 ]; then
        echo "SYSTEM IS UNFROZEN"
        printf  "`date` SYSTEM IS UNFROZEN\n" >> $log_path
else
        echo "SYSTEM UNFREEZE FAILED"
        printf  "SYSTEM UNFREEZE FAILED\n" >> $log_path
        status=$error
fi

É isto! Estão prontos seus scripts para executar snapshot sem problemas.

Obrigada por ler e sinta-se à vontade para compartilhar ideias e dúvidas nos comentários.

Discussão (0)1
Entre ou crie uma conta para continuar
Pergunta
· Out. 10, 2024

New to working with files in Intersystems

Hi there, 

I'm hoping that someone may be able to point me in the right direction to get started with working with files in Intersystems. I am currently trying to build an interface that will consume a text file containing a list of IDs (one per line) and then write those IDs to an external database. I am comfortable working with the database end but have not worked with files/Stream containers etc yet.

I am struggling with the BP logic as I can't figure out how to access the data within the stream container. My Trace Statements don't appear in the management console when checking despite Trace Logging enabled on the BP.

I really appreciate your time and your help,

Thanks

Dan

My rudimentary ObjectScript looks as follows:

Class ELHTPRODPKG.Interfaces.LancsCare.Processes.LancsCareCSVProcess Extends Ens.BusinessProcess
{ Method OnRequest(pRequest As Ens.StreamContainer, Output pResponse As %Persistent) As %Status
{
        Set sc = $$$OK
        
        // Create a new stream to read the content
        
        $$$TRACE("Step 1")
        
        Set tStreamFile = pRequest.StreamGet()
        
        Set fileContent = tStreamFile.Read()
                
        $$$TRACE("File Content: "_fileContent)
        
    //Set pResponse = sc //Return the status of the operation
    Quit sc  // Return status
}

6 Comments
Discussão (6)2
Entre ou crie uma conta para continuar